Type Parameters

  • T

Hierarchy

  • EventEmitter
    • default

Indexable

  • [key: string]: any

Constructors

Properties

_database: default
_dataKeys: string[] = []
_mutex: default = ...
data: Record<PropertyKey, T> = {}
dirty: boolean = false
Document: new <T>(data: T) => default<T>
each: {
    (iterator: (value: default<T>, index: number) => void): void;
    (
        iterator: (value: T, index: number) => void,
        options: Partial<Omit<Options, "lean">> & { lean: true },
    ): void;
    (
        iterator: (value: default<T>, index: number) => void,
        options: Partial<Omit<Options, "lean">> & { lean: false },
    ): void;
    (
        iterator: (value: default<T>, index: number) => void,
        options: Partial<Omit<Options, "lean">> & { lean?: undefined },
    ): void;
    (
        iterator:
            | (value: T, index: number) => void
            | (value: default<T>, index: number) => void,
        options: Partial<Options>,
    ): void;
}

Type declaration

    • (iterator: (value: default<T>, index: number) => void): void
    • Iterates over all documents.

      Parameters

      • iterator: (value: default<T>, index: number) => void

      Returns void

    • (
          iterator: (value: T, index: number) => void,
          options: Partial<Omit<Options, "lean">> & { lean: true },
      ): void
    • Iterates over all documents.

      Parameters

      • iterator: (value: T, index: number) => void
      • options: Partial<Omit<Options, "lean">> & { lean: true }

      Returns void

    • (
          iterator: (value: default<T>, index: number) => void,
          options: Partial<Omit<Options, "lean">> & { lean: false },
      ): void
    • Iterates over all documents.

      Parameters

      Returns void

    • (
          iterator: (value: default<T>, index: number) => void,
          options: Partial<Omit<Options, "lean">> & { lean?: undefined },
      ): void
    • Iterates over all documents.

      Parameters

      Returns void

    • (
          iterator:
              | (value: T, index: number) => void
              | (value: default<T>, index: number) => void,
          options: Partial<Options>,
      ): void
    • Iterates over all documents.

      Parameters

      Returns void

get: {
    (id: PropertyKey): default<T>;
    (
        id: PropertyKey,
        options_: Partial<Omit<Options, "lean">> & { lean: true },
    ): T;
    (
        id: PropertyKey,
        options_: Partial<Omit<Options, "lean">> & { lean: false },
    ): default<T>;
    (
        id: PropertyKey,
        options_: Partial<Omit<Options, "lean">> & { lean?: undefined },
    ): default<T>;
    (id: PropertyKey, options_: Partial<Options>): T | default<T>;
}

Type declaration

    • (id: PropertyKey): default<T>
    • Finds a document by its identifier.

      Parameters

      • id: PropertyKey

      Returns default<T>

    • (id: PropertyKey, options_: Partial<Omit<Options, "lean">> & { lean: true }): T
    • Finds a document by its identifier.

      Parameters

      • id: PropertyKey
      • options_: Partial<Omit<Options, "lean">> & { lean: true }

      Returns T

    • (
          id: PropertyKey,
          options_: Partial<Omit<Options, "lean">> & { lean: false },
      ): default<T>
    • Finds a document by its identifier.

      Parameters

      • id: PropertyKey
      • options_: Partial<Omit<Options, "lean">> & { lean: false }

      Returns default<T>

    • (
          id: PropertyKey,
          options_: Partial<Omit<Options, "lean">> & { lean?: undefined },
      ): default<T>
    • Finds a document by its identifier.

      Parameters

      • id: PropertyKey
      • options_: Partial<Omit<Options, "lean">> & { lean?: undefined }

      Returns default<T>

    • (id: PropertyKey, options_: Partial<Options>): T | default<T>
    • Finds a document by its identifier.

      Parameters

      • id: PropertyKey
      • options_: Partial<Options>

      Returns T | default<T>

length: number = 0
name: string

Model name

Query: new <T>(data: default<T>[]) => default<T>
random: () => default<T>

Type declaration

schema: default<T>
size: () => number

Type declaration

    • (): number
    • Returns the number of elements.

      Returns number

Accessors

  • get dataKeys(): string[]
  • Returns the cached data keys.

    Returns string[]

Methods

  • Returns the number of elements.

    Returns number

  • Deletes a model.

    Returns void

  • Returns the document at the specified index. num can be a positive or negative number.

    Parameters

    • i_: number

    Returns default<T>

  • Returns the document at the specified index. num can be a positive or negative number.

    Parameters

    Returns T

  • Returns the document at the specified index. num can be a positive or negative number.

    Parameters

    Returns default<T>

  • Returns the document at the specified index. num can be a positive or negative number.

    Parameters

    Returns default<T>

  • Returns the document at the specified index. num can be a positive or negative number.

    Parameters

    Returns T | default<T>

  • Tests whether all documents pass the test implemented by the provided function.

    Parameters

    • iterator: (value: default<T>, index: number) => boolean

    Returns boolean

  • Creates a new array with all documents that pass the test implemented by the provided function.

    Parameters

    • iterator: (value: default<T>, index: number) => boolean

    Returns default<T>

  • Creates a new array with all documents that pass the test implemented by the provided function.

    Parameters

    • iterator: (value: T, index: number) => boolean
    • options: Partial<Omit<Options, "lean">> & { lean: true }

    Returns default<T>

  • Creates a new array with all documents that pass the test implemented by the provided function.

    Parameters

    • iterator: (value: default<T>, index: number) => boolean
    • options: Partial<Omit<Options, "lean">> & { lean: false }

    Returns default<T>

  • Creates a new array with all documents that pass the test implemented by the provided function.

    Parameters

    • iterator: (value: default<T>, index: number) => boolean
    • options: Partial<Omit<Options, "lean">> & { lean?: undefined }

    Returns default<T>

  • Creates a new array with all documents that pass the test implemented by the provided function.

    Parameters

    • iterator:
          | (value: T, index: number) => boolean
          | (value: default<T>, index: number) => boolean
    • options: Partial<Options>

    Returns default<T>

  • Finds matching documents.

    Parameters

    • query: object

    Returns default<T>

  • Finds matching documents.

    Parameters

    • query: object
    • options: Partial<Omit<Options, "lean">> & { lean: true }
      • limit

        Limits the number of documents returned.

      • skip

        Skips the first elements.

      • lean

        Returns a plain JavaScript object.

      • lean: true

        Returns a plain JavaScript object.

    Returns T[]

  • Finds matching documents.

    Parameters

    • query: object
    • options: Partial<Omit<Options, "lean">> & { lean: false }
      • limit

        Limits the number of documents returned.

      • skip

        Skips the first elements.

      • lean

        Returns a plain JavaScript object.

      • lean: false

        Returns a plain JavaScript object.

    Returns default<T>

  • Finds matching documents.

    Parameters

    • query: object
    • options: Partial<Omit<Options, "lean">> & { lean?: undefined }
      • limit

        Limits the number of documents returned.

      • skip

        Skips the first elements.

      • lean

        Returns a plain JavaScript object.

      • Optionallean?: undefined

        Returns a plain JavaScript object.

    Returns default<T>

  • Finds matching documents.

    Parameters

    • query: object
    • options: Partial<Options>
      • limit

        Limits the number of documents returned.

      • skip

        Skips the first elements.

      • lean

        Returns a plain JavaScript object.

    Returns T[] | default<T>

  • Finds a document by its identifier.

    Parameters

    • id: PropertyKey

    Returns default<T>

  • Finds a document by its identifier.

    Parameters

    • id: PropertyKey
    • options_: Partial<Omit<Options, "lean">> & { lean: true }

    Returns T

  • Finds a document by its identifier.

    Parameters

    • id: PropertyKey
    • options_: Partial<Omit<Options, "lean">> & { lean: false }

    Returns default<T>

  • Finds a document by its identifier.

    Parameters

    • id: PropertyKey
    • options_: Partial<Omit<Options, "lean">> & { lean?: undefined }

    Returns default<T>

  • Finds a document by its identifier.

    Parameters

    • id: PropertyKey
    • options_: Partial<Options>

    Returns T | default<T>

  • Finds the first matching documents.

    Parameters

    • query: object

    Returns default<T>

  • Finds the first matching documents.

    Parameters

    • query: object
    • options_: Partial<Omit<Options, "lean">> & { lean: true }

    Returns T

  • Finds the first matching documents.

    Parameters

    • query: object
    • options_: Partial<Omit<Options, "lean">> & { lean: false }

    Returns default<T>

  • Finds the first matching documents.

    Parameters

    • query: object
    • options_: Partial<Omit<Options, "lean">> & { lean?: undefined }

    Returns default<T>

  • Finds the first matching documents.

    Parameters

    • query: object
    • options_: Partial<Options>

    Returns T | default<T>

  • Iterates over all documents.

    Parameters

    • iterator: (value: default<T>, index: number) => void

    Returns void

  • Iterates over all documents.

    Parameters

    • iterator: (value: T, index: number) => void
    • options: Partial<Omit<Options, "lean">> & { lean: true }

    Returns void

  • Iterates over all documents.

    Parameters

    Returns void

  • Iterates over all documents.

    Parameters

    Returns void

  • Iterates over all documents.

    Parameters

    Returns void

  • Checks if the model contains a document with the specified id.

    Parameters

    • id: PropertyKey

    Returns boolean

  • Creates an array of values by iterating each element in the collection.

    Type Parameters

    • R

    Parameters

    • iterator: (value: default<T>, index: number) => R

    Returns R[]

  • Creates an array of values by iterating each element in the collection.

    Type Parameters

    • R

    Parameters

    • iterator: (value: T, index: number) => R
    • options: Partial<Omit<Options, "lean">> & { lean: true }

    Returns R[]

  • Creates an array of values by iterating each element in the collection.

    Type Parameters

    • R

    Parameters

    • iterator: (value: default<T>, index: number) => R
    • options: Partial<Omit<Options, "lean">> & { lean: false }

    Returns R[]

  • Creates an array of values by iterating each element in the collection.

    Type Parameters

    • R

    Parameters

    • iterator: (value: default<T>, index: number) => R
    • options: Partial<Omit<Options, "lean">> & { lean?: undefined }

    Returns R[]

  • Creates an array of values by iterating each element in the collection.

    Type Parameters

    • R

    Parameters

    • iterator: (value: T, index: number) => R | (value: default<T>, index: number) => R
    • options: Partial<Options>

    Returns R[]

  • Reduces a collection to a value which is the accumulated result of iterating each element in the collection.

    Type Parameters

    • R

    Parameters

    • iterator: (pre: any, cur: default<T>, index: number) => R
    • Optionalinitial: R

      By default, the initial value is the first document.

    Returns R

  • Reduces a collection to a value which is the accumulated result of iterating each element in the collection from right to left.

    Type Parameters

    • R

    Parameters

    • iterator: (pre: any, cur: default<T>, index: number) => R
    • Optionalinitial: R

      By default, the initial value is the last document.

    Returns R

  • Returns the specified range of documents.

    Parameters

    • Optionalstart_: number
    • Optionalend_: number

    Returns default<T>

  • Tests whether some documents pass the test implemented by the provided function.

    Parameters

    • iterator: (value: default<T>, index: number) => boolean

    Returns boolean

  • Sorts documents. See Query#sort.

    Parameters

    • orderby: string
    • Optionalorder: number | "desc" | Record<string, any>

    Returns default<T>

  • Sorts documents. See Query#sort.

    Parameters

    • orderby: string

    Returns default<T>

  • Sorts documents. See Query#sort.

    Parameters

    • orderby: Record<string, number | Record<string, any>>

    Returns default<T>

  • Updates matching documents.

    Parameters

    Returns Bluebird<any>

  • Finds a document by its identifier and update it.

    Parameters

    Returns Bluebird<any>