Constructor
# new Database(databaseFileopt, optionsopt)
XenDB Database
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
databaseFile |
String |
<optional> |
"json.sqlite" | The database's file |
|||||||||||||||||||||||||
options |
Object |
<optional> |
Database options Properties
|
Properties
Name | Type | Description |
---|---|---|
database |
SQLite.Database | The main SQLite3 Database |
name |
String | The name of the database |
options |
Object | XenDB options |
rowCount |
Number | The database table's rows count |
- Source:
Extends
- EventEmitter
Members
# database :SQLite.Database
Returns the SQLite3-Database Manager
- SQLite.Database
- Source:
# length :Number
Returns length of this database
- Number
- Source:
# rowCount :Number
Returns number of rows count
- Number
- Source:
Methods
# add(key, value, options)
Add numbers to a key in the database
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
Number | Any numerical value |
options |
Object | Options |
- Source:
# all(options)
Returns used table (or specific table) as array
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
# allTableArray()
Returns all table(s) as array.
- Source:
# array()
Returns an array of this table
- Source:
# createTable(name)
Creates new instance of this database with the specified table
Name | Type | Default | Description |
---|---|---|---|
name |
String | JSON | Table name |
- Source:
# delete(key, options) → {Boolean}
Deletes a data from the specified key
Name | Type | Description |
---|---|---|
key |
String | Key to be delete |
options |
Object | Options |
- Source:
- Type
- Boolean
# deleteAll(optionsopt)
Delete all data in the database
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Options |
- Source:
# divide(key, value, options)
Divide numbers to a key in the database
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
Number | Any numerical value |
options |
Object | Options |
- Source:
# drop(options) → {Boolean}
Drops currently active/specified table
Name | Type | Description |
---|---|---|
options |
Object | Options |
- Source:
- Type
- Boolean
# endsWith(key, options)
Alias of Database.all()
but easier to sort by key
Name | Type | Description |
---|---|---|
key |
String | The key of the data |
options |
Object | Options |
- Source:
# eval(x)
Evaluate anything inside the Database
class using this
Name | Type | Description |
---|---|---|
x |
any | Value to be evaluated |
- Source:
# every(fn, options)
Identical to Array.every
Name | Type | Description |
---|---|---|
fn |
function | A function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array. |
options |
Object | Options |
- Source:
# export(options)
Exports this db
Name | Type | Description |
---|---|---|
options |
Object | Export options |
- Deprecated:
- Yes
- Source:
# extract(key, value, options)
Extract a value from an array. Alias of Database.pull()
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
any | The value that wanted to be extracted |
options |
Object | Options |
- Source:
# fetch(key, options)
Returns saved data from this database. Alias of Database.get()
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
options |
Object | Options |
- Source:
# fetchAll(options)
Alias of Database.all()
Name | Type | Description |
---|---|---|
options |
Object | Options |
- Source:
# fetchOne(key, value, options)
Fetch a specific value from the database
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
any | The value that wanted to be fetched |
options |
Object | Options |
- Source:
# filter(fn, options)
Identical to Array.filter
Name | Type | Description |
---|---|---|
fn |
function | A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. |
options |
Object | Options |
- Source:
# find(fn, options)
Identical to Array.find
Name | Type | Description |
---|---|---|
fn |
function | find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined. |
options |
Object | Options |
- Source:
# findIndex(fn, options)
Identical to Array.findIndex
Name | Type | Description |
---|---|---|
fn |
function | find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1. |
options |
Object | Options |
- Source:
# flatMap(fn, options)
Identical to Array.flatMap
Name | Type | Description |
---|---|---|
fn |
function | Function that produces an element of the new Array, taking three arguments. |
options |
Object | Options |
- Source:
# forEach(fn, options)
Identical to Array.forEach
Name | Type | Description |
---|---|---|
fn |
function | A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. |
options |
Object | Options |
- Source:
# get(key, options)
Returns saved data from this database. Alias of Database.fetch()
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
options |
Object | Options |
- Source:
# getOne(key, value, options)
Get a specific value from the database. Alias of Database.fetchOne()
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
any | The value that wanted to be fetched |
options |
Object | Options |
- Source:
# has(key, options) → {Boolean}
Checks if there is any matching value with provided key
Name | Type | Description |
---|---|---|
key |
String | Key to match |
options |
Object | Options |
- Source:
- Type
- Boolean
# includes(key, options) → {Boolean}
Alias of db.has
Name | Type | Description |
---|---|---|
key |
String | Key |
options |
Object | Options |
- Source:
- Type
- Boolean
# indexOf(searchElement, fromIndex, options)
Identical to Array.indexOf
Name | Type | Default | Description |
---|---|---|---|
searchElement |
any | The value to locate in the array. |
|
fromIndex |
Number | 0 | The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. |
options |
Object | Options |
- Source:
# init() → {void}
Fired when the database is ready
- Source:
- Type
- void
# keyArray(options)
Returns array of keys
Name | Type | Description |
---|---|---|
options |
Object | Options |
- Source:
# map(fn, options)
Identical to Array.map
Name | Type | Description |
---|---|---|
fn |
function | A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. |
options |
Object | Options |
- Source:
# modulus(key, value, options)
Modulus for existing data with the given numerical value.
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
Number | Numerical value |
options |
Object | Options |
- Source:
# multiply(key, value, options)
Multiply numbers to a key in the database
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
Number | Any numerical value |
options |
Object | Options |
- Source:
# prepareTable(nameopt)
Prepares a tabe
Name | Type | Attributes | Description |
---|---|---|---|
name |
String |
<optional> |
The table name |
- Source:
# pull(key, value, options)
Extract a value from an array (Reverse of Database.push()
)
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
any | The value that wanted to be extracted/pull |
options |
Object | Options |
- Source:
# push(key, value, options)
Push an array type value into the database key
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
any | Value to store (or push into the key) |
options |
Object | Options |
- Source:
# reduce(fn, initialValue, options)
Identical to Array.reduce
Name | Type | Description |
---|---|---|
fn |
function | A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. |
initialValue |
Object | If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. |
options |
Object | Options |
- Source:
# reduceRight(fn, initialValue, options)
Identical to Array.reduceRight
Name | Type | Description |
---|---|---|
fn |
function | A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. |
initialValue |
Object | If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. |
options |
Object | Options |
- Source:
# set(key, value, options)
Set or re-writes data in this database key
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
any | Value to store |
options |
Object | Options |
- Source:
# size()
Returns the database file size in bytes
- Source:
# some(fn, options)
Identical to Array.some
Name | Type | Description |
---|---|---|
fn |
function | A function that accepts up to three arguments. The some method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value true, or until the end of the array. |
options |
Object | Options |
- Source:
# sort(fn, options)
Identical to Array.sort
Name | Type | Description |
---|---|---|
fn |
function | Function used to determine the order of the elements. It is expected to return a negative value if first argument is less than second argument, zero if they're equal and a positive value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. |
options |
Object | Options |
- Source:
# startsWith(key, options)
Alias of Database.all()
but easier to sort by key
Name | Type | Description |
---|---|---|
key |
String | The key of the data |
options |
Object | Options |
- Source:
# subtract(key, value, options)
Subtract numbers to a key from the database
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
value |
Number | Any numerical value |
options |
Object | Options |
- Source:
# tables()
Returns all table name
- Source:
# toJSON(options)
Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization.
Name | Type | Description |
---|---|---|
options |
Object | Options |
- Source:
# toString()
Returns a value representation of an array
- Source:
# type(key, options)
Returns data type of fetched data
Name | Type | Description |
---|---|---|
key |
String | Key of the data |
options |
Object | Options |
- Source:
# use(database)
This method updates current database manager with a new one. Database parameter can either be Database
instance or BetterSQLite3.Database
instance
Name | Type | Description |
---|---|---|
database |
any | The database |
- Source:
# valueArray(options)
Returns array of values
Name | Type | Description |
---|---|---|
options |
Object | Options |
- Source: