πŸ“šDocumentation

Methods

.table(name)

This function creates a new table, allowing you to separate your data while being used exactly the same.

const economy = db.table('economy')
await economy.set('myBalance', 500) // -> 500
await economy.get('myBalance') // -> 500
await db.get('myBalance') // -> null

.add(key, number) -> updatedRow

This function adds a number to a key in the database. (If no existing number, it will add to 0)

await db.get('myBalance')
// -> 500

await db.add('myBalance', 250)
// -> 750

Also allows for accessing properties using dot notation

await db.get('myUser')
// -> { guild: null, balance: 500 }

await db.add('myUser.balance', 250)
// -> { guild: null, balance: 750 }

.all() -> array

This function returns the entire active table as an array.

.delete(key) -> boolean

This function deletes the specified key. Returns if it was a success or not.

Also allows for accessing properties using dot notation

.deleteAll() -> number

This function delete all there is in the database (or the table) It returns the numbers of rows deleted

.get(key) -> row

This function returns data from a row based on the key. Alias: .fetch()

Also allows for accessing properties using dot notation

.has(key) -> boolean

This function returns a boolean based on whether an element or property exists. Alias: .exists()

Also allows for accessing properties using dot notation

.push(key, element) -> updatedRow

This function will push into an array in the database based on the key. (If no existing array, it will create one)

Also allows for accessing properties using dot notation

.pull(key, [value|array|function]) -> updatedRow

This function removes a value from an array (reverse operation from push). The second parameter can be a simple value, an array or a function. When used with a function, it will only remove the value when the function returns true

.set(key, data) -> updatedRow

This function sets new data based on a key in the database. (When using dot notation, if the object doesn't exist it'll create one)

Also allows for accessing properties using dot notation

.sub(key, number) -> updatedRow

This function subtracts a number to a key in the database. (If no existing number, it will subtract from 0)

Also allows for accessing properties using dot notation

Last updated