Class Client<M>

Type Parameters

Hierarchy

  • BaseClient
    • Client

Constructors

  • Client class for handling operations on a JSON data store.

    Type Parameters

    Parameters

    Returns Client<M>

Properties

cache: Map<string, {
    [key: string]: JSONDataTypes;
}[]> = ...

Methods

  • Clears all records from the specified tables.

    Type Parameters

    • T extends string

      Table name type.

    Parameters

    • Rest ...tables: T[]

      Tables to clear records from.

    Returns this

    • Current instance for method chaining.
  • Counts the number of records that match the specified criteria in the given table.

    Type Parameters

    • T extends string

      Table name type.

    • C extends {
          _id: string;
          [key: string]: JSONDataTypes;
      }

      Columns type of the table.

    Parameters

    • table: T

      The name of the table to count the records from.

    • where: {
          [K in string | number | symbol]?: ((value) => boolean)
      }

      Criteria to filter records.

    • Optional query: QueryOptions<C>

      Additional options like sorting, limiting, and projection.

    Returns number

    • Number of records that match the criteria.
  • Type Parameters

    • T extends string

    Parameters

    • Rest ...tables: T[]

    Returns this

  • Deletes records from the specified table based on the given criteria.

    Type Parameters

    • T extends string

      Table name type.

    • C extends {
          _id: string;
          [key: string]: JSONDataTypes;
      }

      Columns type of the table.

    Parameters

    • table: T

      The name of the table to delete from.

    • Optional where: {
          [K in string | number | symbol]?: ((value) => boolean)
      }

      Criteria to filter records to delete.

    Returns number

    • Number of records deleted.
  • Deletes first record from the specified table based on the given criteria.

    Type Parameters

    • T extends string

      Table name type.

    • C extends {
          _id: string;
          [key: string]: JSONDataTypes;
      }

      Columns type of the table.

    Parameters

    • table: T

      The name of the table to delete from.

    • Optional where: {
          [K in string | number | symbol]?: ((value) => boolean)
      }

      Criteria to filter records to delete.

    Returns number

    • Number of records deleted.
  • Drops specified tables from the database.

    Type Parameters

    • T extends string

      Table name type.

    Parameters

    • Rest ...tables: T[]

      Tables to drop from the database.

    Returns Record<string, Record<string, JSONDataTypes>[]>

    • Updated JSON data after dropping tables.
  • Filters records in the specified table based on the given criteria.

    Type Parameters

    • T extends string

      Table name type.

    • C extends {
          _id: string;
          [key: string]: JSONDataTypes;
      }

      Columns type of the table.

    Parameters

    • table: T

      The name of the table to filter.

    • where: {
          [K in string | number | symbol]?: ((value) => boolean)
      }

      Criteria to filter records.

    • Optional query: QueryOptions<C>

      Additional options like sorting, limiting, and projection.

    Returns C[]

    • Array of filtered records.
  • Filters records in the specified table based on the given criteria, returns the first record.

    Type Parameters

    • T extends string

      Table name type.

    • C extends {
          _id: string;
          [key: string]: JSONDataTypes;
      }

      Columns type of the table.

    Parameters

    • table: T

      The name of the table to filter.

    • where: {
          [K in string | number | symbol]?: ((value) => boolean)
      }

      Criteria to filter records.

    • Optional query: QueryOptions<C>

      Additional options like sorting, limiting, and projection.

    Returns null | C

    • Filtered record.
  • Type Parameters

    • T extends string
    • C extends {
          _id: string;
          [key: string]: JSONDataTypes;
      }

    Parameters

    • table: T
    • Rest ...data: Omit<C, "_id">[]

    Returns C[]

  • Parameters

    • json: undefined | boolean = false

    Returns {
        [key: string]: {
            [key: string]: JSONDataTypes;
        }[];
    }

  • Retrieves the number of records in a specific table or the total number of tables if no table is specified.

    Type Parameters

    • T extends string

      Table name type.

    Parameters

    • Optional table: T

      Optional. The table to get the size of.

    Returns number

    • Number of records in the specified table or total number of tables if no table is specified.
  • Updates records in the specified table based on the given criteria and update values.

    Type Parameters

    • T extends string

      Table name type.

    • C extends {
          _id: string;
          [key: string]: JSONDataTypes;
      }

      Columns type of the table.

    Parameters

    • table: T

      The name of the table to update.

    • Optional where: {
          [K in string | number | symbol]?: ((value) => boolean)
      }

      Criteria to filter records to update.

    • updates: Partial<Omit<C, "_id">>

      Update values for the records.

    Returns C[]

    • Number of records updated.
  • Parameters

    • data: {
          [key: string]: {
              [key: string]: JSONDataTypes;
          }[];
      }
    • updateCache: boolean = true

    Returns this