BetterQDB
Quick.db but with a slight few adjustments. Added more functions/methods to fiddle around with. Fixed Bugs that quick.db could not offer at the moment.
Original Makers | Discord Support (600+ Members) | NPM Page |
---|---|---|
Quick.db | discord.gg/WYH6n6w | Coming Soon |
Introduction
Most functions shown are similar to the original quick.db documentation. This package just altars everything. Credit to TrueXPixels
const db = ; // Setting an object into the key "Bob"db// Whole key returns -> { health: 100, mana: 100 } // Pushing an element into an array ( This array does not exist yet )db// Whole key returns -> { health: 100, mana: 100, inventory: ['Apple'] }// Bob.inventory returns => ['Apple'] // Adding a number to a new field ( This field does not exist yet )db// Whole key returns -> { health: 100, mana: 100, inventory: ['Apple'], balance: 500 }// Bob.balance returns => 500 // Repeating previous examples:db// Whole key returns -> { health: 100, mana: 100, inventory: ['Apple', 'Grape'], balance: 500 }// Bob.items returns => ['Apple', 'Grape'] db// Whole key returns -> { health: 100, mana: 100, inventory: ['Apple', 'Grape'], balance: 1000 }// Bob.balance returns => 1000 // Fetching individual properties// Using either .get or .fetch works db // -> 1000db // ['Sword', 'Watch']
Documentation
Methods
- new db.table(name)
- add(key, number, [options])
- .all() -> array
- .delete(key, [options])
- get(key, [options])
- .has(key, [options])
- .push(key, element, [options])
- .set(key, data, [options])
- .subtract(key, number, [options])
new .table(name)
This function creates a new table, allowing you to separate your data while being used exactly the same.
const db = ; let economy = 'economy'economy // output -> 500economy // output -> 500db // output -> null
.add(key, number, [options])
This function adds a number to a key in the database. (If no existing number, it will add to 0)
db // output -> 500db // output -> 750
Also allows for accessing properties using dot notation
db output // -> { guild: null, balance: 500 }db // output -> { guild: null, balance: 750 }
.all() -> array
This function returns the entire active table as an array.
dball // output -> [Array]
.delete(key, [options])
This function deletes the specified key. Returns if it was a success or not.
db // -> "Hello World!"db // true
Also allows for accessing properties using dot notation
db // output -> { guild: null, balance: 500 }db // output -> truedb // output -> { guild: null }
.get(key, [options])
This function returns data from a row based on the key. Alias: .fetch()
db // output -> 'Hello World!'db // output -> 'Hello World!'
Also allows for accessing properties using dot notation\
db // output -> { guild: 'Plixi Divilopmint', balance: 500 }db // output -> "Plixi Divilopmint"db // output -> 500db // output -> undefined
.has(key, [options])
This function returns a boolean based on whether an element or property exists. Alias: .exists()
db // output -> 'Hello World!'db // output -> true
Also allows for accessing properties using dot notation
db // output -> { guild: 'Plixi Divilopmint', balance: 500 } db // output -> truedb // output -> false
.push(key, element, [options])
This function will push into an array in the database based on the key. (If no existing array, it will create one)
db // output -> ['Grape', 'Apple']db // output -> ['Grape', 'Apple', 'Pear']
Also allows for accessing properties using dot notation
db // output -> { balance: 500, inventory: ['Grape', 'Apple'] }db // output -> { balance: 500, items: ['Grape', 'Apple', 'Pear'] }
.set(key, data, [options])
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)
db // output -> 'Hello World!'db // output -> 50db // output -> { foo: 'bar' }
Also allows for accessing properties using dot notation
db // -> nulldb // output -> { guild: { rank: 'Plixi Pro' } }db // output -> { guild: { rank: 'Plixi Pro' }, balance: 500 }db // output -> { guild: { rank: 'Plixi Overlord' }, balance: 500 }
.subtract(key, number, [option])
This function subtracts a number to a key in the database. (If no existing number, it will subtract from 0)
db // output -> 500db // output -> 300
Also allows for accessing properties using dot notation
db // output -> { league: 'Gold', XP: 500 }db // output -> { league: 'Gold', XP: 300 }