GoodDB
    Preparing search index...

    Interface IAsyncGoodDB

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

      A promise that resolves to the new value.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.add('key', 1);
    • Get all the data.

      Parameters

      • Optionaltype: "object" | "array"

        The type to get the data in.

      Returns Promise<any>

      A promise that resolves to the data.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.all('array');
    • Clear all the data.

      Returns Promise<boolean>

      A promise that resolves to a boolean indicating the success of the operation.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.clear();
    • Connect to the database.

      Returns Promise<boolean>

      A promise that resolves to a boolean indicating the success of the operation.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
    • Delete a key and its associated value.

      Parameters

      • key: string

        The key to delete.

      • Optionaloptions: methodOptions

        The options to use.

      Returns Promise<boolean>

      A promise that resolves to a boolean indicating the success of the operation.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.delete('key');
    • Disconnect from the database.

      Returns Promise<boolean>

      A promise that resolves to a boolean indicating the success of the operation.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.disconnect();
    • 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 Promise<boolean>

      A promise that resolves to a boolean indicating whether any value was removed.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<number>

      A promise that resolves to the new value.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<any>

      A promise that resolves to the values that end with the key.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<any[]>

      A promise that resolves to 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 Promise<any>

      A promise that resolves to the value found.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<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 Promise<any[]>

      A promise that resolves to an array of updated elements.

    • Get the value associated with a key.

      Parameters

      • key: string

        The key to get the value from.

      • Optionaloptions: methodOptions

        The options to use.

      Returns Promise<any>

      A promise that resolves to the value associated with the key.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<boolean>

      A promise that resolves to a boolean indicating whether the key exists.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<any>

      A promise that resolves to a boolean indicating whether the key includes the value.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.includes('key');
    • Get all the keys.

      Returns Promise<string[]>

      A promise that resolves to an array of all the keys.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<number>

      A promise that resolves to the result of the mathematical operation.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<number>

      A promise that resolves to the new value.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<any>

      A promise that resolves to the popped value.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<boolean>

      A promise that resolves to a boolean indicating whether any value was pulled.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<number>

      A promise that resolves to the new length of the array.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<boolean>

      A promise that resolves to a boolean indicating the success of the operation.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.set('key', 'value');
      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<any>

      A promise that resolves to the shifted value.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<number>

      A promise that resolves to the size of the key.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<any>

      A promise that resolves to the values that start with the key.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<number>

      A promise that resolves to the new value.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.subtract('key', 1);
    • Get a table.

      Parameters

      • name: string

        The name of the table to get.

      Returns Promise<IAsyncGoodDB>

      A promise that resolves to a new instance of AsyncGoodDB representing the table.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      const table = await 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 Promise<string>

      A promise that resolves to a string representing the type of the key.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await 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 Promise<number>

      A promise that resolves to the new length of the array.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.unshift('key', 'value');
    • Get all the values.

      Returns Promise<any[]>

      A promise that resolves to an array of all the values.

      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));
      await db.connect();
      await db.values();