GoodDB
    Preparing search index...

    Interface ISyncGoodDB

    interface ISyncGoodDB {
        add(key: string, value: number, options?: methodOptions): number;
        all(type?: "object" | "array"): any;
        clear(): boolean;
        delete(key: string, options?: methodOptions): boolean;
        deleteMany(keys: string[], options?: methodOptions): boolean;
        distinct(
            key: string,
            value?: (value: any, index: number, obj: any[]) => any,
            options?: methodOptions,
        ): boolean;
        double(key: string, options?: methodOptions): number;
        endsWith(key: string, options?: methodOptions): any;
        filter(
            key: string,
            callback: (value: any, index: number, obj: any[]) => unknown,
            options?: methodOptions,
        ): any[];
        find(
            key: string,
            callback: (value: any, index: number, obj: any[]) => unknown,
            options?: methodOptions,
        ): any;
        findAndUpdate(
            key: string,
            findCallback: (value: any, index: number, obj: any[]) => unknown,
            updateCallback: (value: any, index: number, obj: any[]) => any,
            options?: methodOptions,
        ): any;
        findAndUpdateMany(
            key: string,
            findCallback: (value: any, index: number, obj: any[]) => unknown,
            updateCallback: (value: any, index: number, obj: any[]) => any,
            options?: methodOptions,
        ): any[];
        get(key: string, options?: methodOptions): any;
        getMany(keys: string[], options?: methodOptions): Record<string, any>;
        has(key: string, options?: methodOptions): boolean;
        includes(key: string, options?: methodOptions): any;
        keys(): string[];
        math(
            key: string,
            mathSign: MathSigns,
            value: number,
            options?: methodOptions,
        ): number;
        multiply(key: string, value: number, options?: methodOptions): number;
        pop(key: string, options?: methodOptions): any;
        pull(
            key: string,
            valueOrCallback: (e: any, i: number, a: any) => any,
            pullAll?: boolean,
            options?: methodOptions,
        ): boolean;
        push(key: string, value: any, options?: methodOptions): number;
        set(key: string, value: any, options?: methodOptions): boolean;
        setMany(data: Record<string, any>, options?: methodOptions): boolean;
        shift(key: string, options?: methodOptions): any;
        size(key: string, options?: methodOptions): number;
        startsWith(key: string, options?: methodOptions): any;
        subtract(key: string, value: number, options?: methodOptions): number;
        table(name: string): ISyncGoodDB;
        type(key: string, options?: methodOptions): string;
        unshift(key: string, value: any, options?: methodOptions): number;
        values(): any[];
    }
    Index

    Methods

    • Add a value to a key

      Parameters

      • key: string

        The key to add the value to

      • value: number

        The value to add

      • Optionaloptions: methodOptions

        The options to use

      Returns number

      A number

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.add('key', 1);
    • Get all the data

      Parameters

      • Optionaltype: "object" | "array"

        The type to get the data in

      Returns any

      The data

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.all('array');
    • Clear all the data

      Returns boolean

      A boolean

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.clear();
    • Delete a key

      Parameters

      • key: string

        The key to delete

      • Optionaloptions: methodOptions

        The options to use

      Returns boolean

      A boolean

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.delete('key');
    • Remove all duplicate values from an array stored in a key

      Parameters

      • key: string

        The key of the array to remove duplicate values from

      • Optionalvalue: (value: any, index: number, obj: any[]) => any

        The value to remove

      • Optionaloptions: methodOptions

        The options to use

      Returns boolean

      A boolean

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.distinct('key', 'value');
    • Double the value of a key

      Parameters

      • key: string

        The key to double the value of

      • Optionaloptions: methodOptions

        The options to use

      Returns number

      A number

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.double('key');
    • Get all the values that end with a key

      Parameters

      • key: string

        The key to check if it ends with the value

      • Optionaloptions: methodOptions

        The options to use

      Returns any

      A value

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.endsWith('key');
      • Filter values in an array stored in a key. *

      Parameters

      • key: string

        The key of the array to filter. *

      • callback: (value: any, index: number, obj: any[]) => unknown

        The callback filter function to use. *

      • Optionaloptions: methodOptions

        The options to use. *

      Returns any[]

      An array of filtered values.

    • Find a value in an array stored in a key

      Parameters

      • key: string

        The key of the array to find the value in

      • callback: (value: any, index: number, obj: any[]) => unknown

        The callback function to use for finding the value

      • Optionaloptions: methodOptions

        The options to use

      Returns any

      A value

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.find('key', (value) => value === 'value');
    • Parameters

      • key: string
      • findCallback: (value: any, index: number, obj: any[]) => unknown
      • updateCallback: (value: any, index: number, obj: any[]) => any
      • Optionaloptions: methodOptions

      Returns any

      • Find multiple values in an array and update them. *

      Parameters

      • key: string

        The key of the array to search. *

      • findCallback: (value: any, index: number, obj: any[]) => unknown

        The callback function to find the elements. *

      • updateCallback: (value: any, index: number, obj: any[]) => any

        The callback function to update the found elements. *

      • Optionaloptions: methodOptions

        The options to use. *

      Returns any[]

      An array of updated elements.

    • Get a value from a key

      Parameters

      • key: string

        The key to get the value from

      • Optionaloptions: methodOptions

        The options to use

      Returns any

      A value

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.get('key');
    • Check if a key exists

      Parameters

      • key: string

        The key to check if it exists

      • Optionaloptions: methodOptions

        The options to use

      Returns boolean

      A boolean

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.has('key');
    • Check if a key includes a value

      Parameters

      • key: string

        The key to check if it includes the value

      • Optionaloptions: methodOptions

        The options to use

      Returns any

      A value

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.includes('key');
    • Get all the keys

      Returns string[]

      An array of all the keys

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.keys();
    • Perform a mathematical operation on a key

      Parameters

      • key: string

        The key to perform the mathematical operation on

      • mathSign: MathSigns

        The mathematical sign to use

      • value: number

        The value to use in the mathematical operation

      • Optionaloptions: methodOptions

        The options to use

      Returns number

      A number

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.math('key', '+', 1);
    • Multiply a value to a key

      Parameters

      • key: string

        The key to multiply the value to

      • value: number

        The value to multiply

      • Optionaloptions: methodOptions

        The options to use

      Returns number

      A number

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.multiply('key', 2);
    • Remove and return the last element of an array stored in a key

      Parameters

      • key: string

        The key of the array to pop the value from

      • Optionaloptions: methodOptions

        The options to use

      Returns any

      A value

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.pop('key');
    • Remove one or all occurrences of a value from an array stored in a key

      Parameters

      • key: string

        The key of the array to pull the value from

      • valueOrCallback: (e: any, i: number, a: any) => any

        The value or callback function to use to pull the value

      • OptionalpullAll: boolean

        Whether to pull all occurrences or just the first one

      • Optionaloptions: methodOptions

        The options to use

      Returns boolean

      A boolean

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.pull('key', 'value');
    • Push a value to an array stored in a key

      Parameters

      • key: string

        The key of the array to push the value to

      • value: any

        The value to push

      • Optionaloptions: methodOptions

        The options to use

      Returns number

      A number

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.push('key', 'value');
    • Set a value to a key

      Parameters

      • key: string

        The key to set the value to

      • value: any

        The value to set

      • Optionaloptions: methodOptions

        The options to use

      Returns boolean

      A boolean

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.set('key', 'value');
      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));

      db.set('key', 'value', {
      nested: 'nested',
      nestedIsEnabled: true
      });
    • Remove and return the first element of an array stored in a key

      Parameters

      • key: string

        The key of the array to shift the value from

      • Optionaloptions: methodOptions

        The options to use

      Returns any

      A value

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.shift('key');
    • Get the size of a key

      Parameters

      • key: string

        The key to get the size of

      • Optionaloptions: methodOptions

        The options to use

      Returns number

      A number

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.size('key');
    • Get all the values that start with a key

      Parameters

      • key: string

        The key to check if it starts with the value

      • Optionaloptions: methodOptions

        The options to use

      Returns any

      A value

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.startsWith('key');
    • Subtract a value from a key

      Parameters

      • key: string

        The key to subtract the value from

      • value: number

        The value to subtract

      • Optionaloptions: methodOptions

        The options to use

      Returns number

      A number

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.subtract('key', 1);
    • Get a table

      Parameters

      • name: string

        The name of the table to get

      Returns ISyncGoodDB

      A new instance of GoodDB representing the table

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.table('table');
    • Get the type of a key

      Parameters

      • key: string

        The key to get the type of

      • Optionaloptions: methodOptions

        The options to use

      Returns string

      A string

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.type('key');
    • Add a value to the beginning of an array stored in a key

      Parameters

      • key: string

        The key of the array to unshift the value to

      • value: any

        The value to unshift

      • Optionaloptions: methodOptions

        The options to use

      Returns number

      A number

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.unshift('key', 'value');
    • Get all the values

      Returns any[]

      An array of all the values

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));
      db.values();