Class default<T>Abstract

Type Parameters

  • T

Constructors

Properties

_model: default<T>
_schema: default<T>
data: default<T>[]
each: (iterator: (item: default<T>, index: number) => void) => void

Type declaration

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

      Parameters

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

      Returns void

length: number
random: () => default<T>

Type declaration

size: () => number

Type declaration

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

      Returns number

      Number

Methods

  • Returns the number of elements.

    Returns number

    Number

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

    Parameters

    • i: number

    Returns default<T>

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

    Parameters

    • iterator: (item: 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: (item: default<T>, index: number) => boolean

    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 default<T> | 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 }
      • skip

        Skips the first elements.

      • lean

        Returns a plain JavaScript object.

      • lean: true

        Returns a plain JavaScript object.

    Returns T

  • Finds the first matching documents.

    Parameters

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

        Skips the first elements.

      • lean

        Returns a plain JavaScript object.

      • lean: false

        Returns a plain JavaScript object.

    Returns default<T>

  • Finds the first matching documents.

    Parameters

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

        Skips the first elements.

      • lean

        Returns a plain JavaScript object.

      • Optionallean?: undefined

        Returns a plain JavaScript object.

    Returns default<T>

  • Finds the first matching documents.

    Parameters

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

        Skips the first elements.

      • lean

        Returns a plain JavaScript object.

    Returns T | default<T>

  • Iterates over all documents.

    Parameters

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

    Returns void

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

    Type Parameters

    • R

    Parameters

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

    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

    • start: number
    • Optionalend: number

    Returns default<T>

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

    Parameters

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

    Returns boolean

  • Sorts documents.

    Example:

    query.sort('date', -1);
    query.sort({date: -1, title: 1});
    query.sort('-date title');

    If the order equals to -1 or desc, the data will be returned in reversed order.

    Parameters

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

    Returns default<T>

  • Sorts documents.

    Example:

    query.sort('date', -1);
    query.sort({date: -1, title: 1});
    query.sort('-date title');

    If the order equals to -1 or desc, the data will be returned in reversed order.

    Parameters

    • orderby: string

    Returns default<T>

  • Sorts documents.

    Example:

    query.sort('date', -1);
    query.sort({date: -1, title: 1});
    query.sort('-date title');

    If the order equals to -1 or desc, the data will be returned in reversed order.

    Parameters

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

    Returns default<T>