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
// Example data in the database
await db.set("myArray", ["test", "other test", "third test", "$special test"]);
// Single value example (removing test)
await db.pull("myArray", "test"); // -> ["other test", "third test", "$special test"]
// Array example (remove other test and third test)
await db.pull("myArray", ["other test", "third test"]); // -> ["$special test"]
// Function example (removing items that starts with $)
// First parameter is the item in the array
// The function is executed for each item
await db.pull("myArray", (item) => item.startsWith("$")); // -> []