Skip to content

Database

Defined in: package/src/index.ts:42

Database class with synchronous methods

Extends

Type Parameters

Type Parameter

T extends string

Constructors

new Database()

new Database<T>(__namedParameters): Database<T>

Defined in: package/src/index.ts:53

Constructs the Database class

Parameters

ParameterType

__namedParameters

DatabaseOptions<T>

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

ParameterType

path

string

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

ParameterType

__namedParameters

SimpleOptions<T>

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

ParameterTypeDescription

auth?

string

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 ParameterDefault type

V

JSObjectN

Parameters
ParameterType

__namedParameters

SimpleOptions<T>

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

V extends JSONValues

Parameters
ParameterType

__namedParameters

KeyedOptions<T>

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
ParameterType

__namedParameters

UnKeyedValuedOptions<T>

Returns

JSObjectN

Call Signature

set(__namedParameters): JSObjectN

Defined in: package/src/index.ts:155

Writes a specific property

Parameters
ParameterType

__namedParameters

KeyedValuedOptions<T, JSONValues>

Returns

JSObjectN


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
ParameterType

__namedParameters

SimpleOptions<T>

Returns

JSObjectN

Call Signature

delete(__namedParameters): JSObjectN

Defined in: package/src/index.ts:183

Deletes a specific property

Parameters
ParameterType

__namedParameters

KeyedOptions<T>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, number>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, number>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, number>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, number>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, number>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, number>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, JSONValues>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, JSONValues>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedValuedOptions<T, JSONValues>

Returns

JSObjectN


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

ParameterType

__namedParameters

KeyedOptions<T>

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

ParameterType

__namedParameters

KeyedOptions<T>

Returns

any