GoodDB
    Preparing search index...

    Interface IGoodDB

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

    Implemented by

    Index

    Methods

    • Add a number to the value stored in a key.

      Parameters

      • key: string

        The key of the value to add to.

      • value: number

        The number to add.

      • Optionaloptions: methodOptions

        The options to use.

      Returns number | Promise<number>

      The new value or a promise that resolves to the new value.

    • Get all the data in the database.

      Parameters

      • Optionaltype: "object" | "array"

        The type of data to return ('object' or 'array').

      Returns any

      All the data or a promise that resolves to all the data.

    • Clear the database.

      Returns boolean | Promise<boolean>

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

    • Connect to the database.

      Returns Promise<boolean>

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

    • Delete a key and its associated value.

      Parameters

      • key: string

        The key to delete.

      • Optionaloptions: methodOptions

        The options to use.

      Returns boolean | Promise<boolean>

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

    • Delete multiple keys at once.

      Parameters

      • keys: string[]

        An array of keys to delete.

      • Optionaloptions: methodOptions

        The options to use.

      Returns boolean | Promise<boolean>

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

    • Disconnect from the database.

      Returns Promise<boolean>

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

    • Get distinct values from an array stored in a key.

      Parameters

      • key: string

        The key of the array to get distinct values from.

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

        The value or callback function to use for getting distinct values.

      • Optionaloptions: methodOptions

        The options to use.

      Returns boolean | Promise<boolean>

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

    • Double the value stored in a key.

      Parameters

      • key: string

        The key of the value to double.

      • Optionaloptions: methodOptions

        The options to use.

      Returns number | Promise<number>

      The new value or a promise that resolves to the new value.

    • Check if a key ends with a specific value.

      Parameters

      • key: string

        The key to check.

      • Optionaloptions: methodOptions

        The options to use.

      Returns any

      The value or a promise that resolves to the value.

    • 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[] | Promise<any[]>

      An array of filtered values or a promise that resolves to an array.

    • Find values in an array stored in a key that satisfy a callback function.

      Parameters

      • key: string

        The key of the array to find values in.

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

        The callback function to use for finding values.

      • Optionaloptions: methodOptions

        The options to use.

      Returns any

      The value or a promise that resolves to the value.

    • Find a value in an array and update it.

      Parameters

      • key: string

        The key of the array to search.

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

        The callback function to find the element.

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

        The callback function to update the found element.

      • Optionaloptions: methodOptions

        The options to use.

      Returns any

      The updated element or undefined if not found, or a promise that resolves to the result.

    • 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[] | Promise<any[]>

      An array of updated elements or 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 any

      The value associated with the key or a promise that resolves to the value.

    • Get multiple values by their keys at once.

      Parameters

      • keys: string[]

        An array of keys to get.

      • Optionaloptions: methodOptions

        The options to use.

      Returns Record<string, any> | Promise<Record<string, any>>

      An object with key-value pairs or a promise that resolves to an object with key-value pairs.

    • Check if a key exists.

      Parameters

      • key: string

        The key to check.

      • Optionaloptions: methodOptions

        The options to use.

      Returns boolean | Promise<boolean>

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

    • Check if a key includes a specific value.

      Parameters

      • key: string

        The key to check.

      • Optionaloptions: methodOptions

        The options to use.

      Returns any

      The value or a promise that resolves to the value.

    • Get all the keys in the database.

      Returns string[] | Promise<string[]>

      An array of keys or a promise that resolves to an array of keys.

    • Perform a mathematical operation on the value stored in a key.

      Parameters

      • key: string

        The key of the value to perform the operation on.

      • mathSign: MathSigns

        The mathematical sign to use for the operation.

      • value: number

        The number to use for the operation.

      • Optionaloptions: methodOptions

        The options to use.

      Returns number | Promise<number>

      The new value or a promise that resolves to the new value.

    • Multiply the value stored in a key by a number.

      Parameters

      • key: string

        The key of the value to multiply.

      • value: number

        The number to multiply by.

      • Optionaloptions: methodOptions

        The options to use.

      Returns number | Promise<number>

      The new value or a promise that resolves to the new value.

    • 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

      The popped value or a promise that resolves to the popped value.

    • 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 | Promise<boolean>

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

    • 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 | Promise<number>

      The new length of the array or a promise that resolves to the new length.

    • 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 | Promise<boolean>

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

    • Set multiple key-value pairs at once.

      Parameters

      • data: Record<string, any>

        An object with key-value pairs to set.

      • Optionaloptions: methodOptions

        The options to use.

      Returns boolean | Promise<boolean>

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

    • 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

      The shifted value or a promise that resolves to the shifted value.

    • Get the size of the value stored in a key.

      Parameters

      • key: string

        The key of the value to get the size of.

      • Optionaloptions: methodOptions

        The options to use.

      Returns number | Promise<number>

      The size of the value or a promise that resolves to the size.

    • Check if a key starts with a specific value.

      Parameters

      • key: string

        The key to check.

      • Optionaloptions: methodOptions

        The options to use.

      Returns any

      The value or a promise that resolves to the value.

    • Subtract a number from the value stored in a key.

      Parameters

      • key: string

        The key of the value to subtract from.

      • value: number

        The number to subtract.

      • Optionaloptions: methodOptions

        The options to use.

      Returns number | Promise<number>

      The new value or a promise that resolves to the new value.

    • Get a table from the database.

      Parameters

      • name: string

        The name of the table.

      Returns IGoodDB | Promise<IGoodDB>

      An instance of the IGoodDB interface or a promise that resolves to an instance of the IGoodDB interface.

    • Get the type of the value stored in a key.

      Parameters

      • key: string

        The key of the value to get the type of.

      • Optionaloptions: methodOptions

        The options to use.

      Returns string | Promise<string>

      The type of the value or a promise that resolves to the type.

    • 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 | Promise<number>

      The new length of the array or a promise that resolves to the new length.

    • Get all the values in the database.

      Returns any[] | Promise<any[]>

      An array of values or a promise that resolves to an array of values.