Database
Defined in: package/src/index.ts:42
Database class with synchronous methods
Extends
unknown
<DatabaseEvents
<T
>>
Type Parameters
Type Parameter |
---|
|
Constructors
new Database()
new Database<T>(__namedParameters): Database<T>
Defined in: package/src/index.ts:53
Constructs the Database class
Parameters
Parameter | Type |
---|---|
|
Returns
Database
<T
>
Overrides
TypedEmitter< DatabaseEvents<T>>.constructor
Properties
root
readonly root: string;
Defined in: package/src/index.ts:46
Relative root directory of the database
tables
readonly tables: T[];
Defined in: package/src/index.ts:48
Tables of the database
auth?
readonly optional auth: string;
Defined in: package/src/index.ts:50
Authentication key for each operation
Methods
sanitize()
sanitize(path): any
Defined in: package/src/index.ts:67
Sanitize an string to use.
Example: If you has {"foo.bar": null}
you must use sanitize("foo.bar")
to access it
Parameters
Parameter | Type |
---|---|
|
|
Returns
any
flat()
flat(__namedParameters): object
Defined in: package/src/index.ts:72
You get an entire table and convert it into a flat object.
Parameters
Parameter | Type |
---|---|
|
Returns
object
all()
all(auth?): Record<T, JSObjectN>
Defined in: package/src/index.ts:81
Gets the contents of all tables and condenses them into a single object
Parameters
Parameter | Type | Description |
---|---|---|
|
| Authentication key |
Returns
Record
<T
, JSObjectN
>
ping()
ping(): number
Defined in: package/src/index.ts:94
Get the ping of the db
Returns
number
begin()
begin(): Promise<void>
Defined in: package/src/index.ts:101
Begins the Database by verifying tables and creating them if they do not exist.
Returns
Promise
<void
>
get()
Get a specific value of a key in the table, or get the entire table.
Call Signature
get<V>(__namedParameters): V
Defined in: package/src/index.ts:134
You get an entire table
Type Parameters
Type Parameter | Default type |
---|---|
|
Parameters
Parameter | Type |
---|---|
|
Returns
V
Call Signature
get<V>(__namedParameters): undefined | V
Defined in: package/src/index.ts:136
Get a specific value of a key in the table
Type Parameters
Type Parameter |
---|
|
Parameters
Parameter | Type |
---|---|
|
|
Returns
undefined
| V
set()
Overwrites a table completely or writes a specific property
Call Signature
set(__namedParameters): JSObjectN
Defined in: package/src/index.ts:153
Overwrite a table completely
Parameters
Parameter | Type |
---|---|
|
Returns
Call Signature
set(__namedParameters): JSObjectN
Defined in: package/src/index.ts:155
Writes a specific property
Parameters
Parameter | Type |
---|---|
|
Returns
delete()
Deletes a table completely or deletes a specific property
Call Signature
delete(__namedParameters): JSObjectN
Defined in: package/src/index.ts:181
Deletes a table completely
Parameters
Parameter | Type |
---|---|
|
Returns
Call Signature
delete(__namedParameters): JSObjectN
Defined in: package/src/index.ts:183
Deletes a specific property
Parameters
Parameter | Type |
---|---|
|
|
Returns
sum()
sum(__namedParameters): JSObjectN
Defined in: package/src/index.ts:201
Adds a quantity to a key, if it does not exist it is created, or if it does exist and it is not a number it is overwritten with the value of the quantity to be added.
Parameters
Parameter | Type |
---|---|
|
|
Returns
sub()
sub(__namedParameters): JSObjectN
Defined in: package/src/index.ts:214
Subtract a quantity from a key, if it does not exist it is created, or if it does exist and it is not a number it is overwritten with the value of the quantity to be subtracted.
Parameters
Parameter | Type |
---|---|
|
|
Returns
multi()
multi(__namedParameters): JSObjectN
Defined in: package/src/index.ts:227
Multiplies a quantity to a key, if it does not exist it is created, or if it does exist and it is not a number it is overwritten with the value of the quantity to be multiplied.
Parameters
Parameter | Type |
---|---|
|
|
Returns
divide()
divide(__namedParameters): JSObjectN
Defined in: package/src/index.ts:240
Divides a quantity to a key, if it does not exist it is created, or if it does exist and it is not a number it is overwritten with the value of 0.
Parameters
Parameter | Type |
---|---|
|
|
Returns
pow()
pow(__namedParameters): JSObjectN
Defined in: package/src/index.ts:253
Raises a quantity to a power in a key, if it does not exist it is created, or if it does exist it is overwritten with the value of 0.
Parameters
Parameter | Type |
---|---|
|
|
Returns
sqrt()
sqrt(__namedParameters): JSObjectN
Defined in: package/src/index.ts:268
Gets a value from a database based on a key. If the value does not exist or is not a number, it is stored as 0. If the value is a number, it is updated with nth root of the value.
Parameters
Parameter | Type |
---|---|
|
|
Returns
push()
push(__namedParameters): JSObjectN
Defined in: package/src/index.ts:282
Pushs a value from the provided key. If the array does not exist or is not an array, then an array containing the given value will be created.
Parameters
Parameter | Type |
---|---|
|
Returns
remove()
remove(__namedParameters): JSObjectN
Defined in: package/src/index.ts:293
Removes a value from the provided key. If the array does not exist or is not an array, then an empty array will be created.
Parameters
Parameter | Type |
---|---|
|
Returns
unshift()
unshift(__namedParameters): JSObjectN
Defined in: package/src/index.ts:309
Adds at the begging the provided values from the provided key. If the array does not exist or is not an array, then an array containing the given value will be created.
Parameters
Parameter | Type |
---|---|
|
Returns
shift()
shift(__namedParameters): any
Defined in: package/src/index.ts:325
Removes and returns the first value from the provided key. If the array does not exist or is not an array, then an empty array will be created.
Parameters
Parameter | Type |
---|---|
|
|
Returns
any
pop()
pop(__namedParameters): any
Defined in: package/src/index.ts:341
Removes and returns the last value from the provided key. If the array does not exist or is not an array, then an empty array will be created.
Parameters
Parameter | Type |
---|---|
|
|
Returns
any