Class default<T>Abstract

Type Parameters

  • T

Constructors

Properties

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

Type declaration

    • (iterator): void
    • Iterates over all documents.

      Parameters

      • iterator: ((item, index) => void)
          • (item, index): void
          • Parameters

            • item: any
            • index: number

            Returns 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, index) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns boolean

    Returns boolean

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

    Parameters

    • iterator: ((item, index) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns boolean

    Returns default<T>

  • Iterates over all documents.

    Parameters

    • iterator: ((item, index) => void)
        • (item, index): void
        • Parameters

          • item: any
          • index: number

          Returns void

    Returns void

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

    Type Parameters

    • T

    Parameters

    • iterator: ((item, index) => T)
        • (item, index): T
        • Parameters

          • item: any
          • index: number

          Returns T

    Returns T[]

  • Populates document references.

    Parameters

    • expr: string | any[] | {
          model?: any;
          path?: string;
          [key: PropertyKey]: any;
      }

    Returns default<T>

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

    Type Parameters

    • R

    Parameters

    • iterator: ((pre, cur, index) => R)
        • (pre, cur, index): R
        • Parameters

          • pre: any
          • cur: any
          • index: number

          Returns R

    • Optional initial: 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, cur, index) => R)
        • (pre, cur, index): R
        • Parameters

          • pre: any
          • cur: any
          • index: number

          Returns R

    • Optional initial: R

      By default, the initial value is the last document.

    Returns R

  • Remove all documents.

    Parameters

    Returns Bluebird<any>

  • Replace all documents.

    Parameters

    Returns Bluebird<any>

  • Returns the specified range of documents.

    Parameters

    • start: number
    • Optional end: number

    Returns default<T>

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

    Parameters

    • iterator: ((item, index) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns 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, desc or descending, the data will be returned in reversed order.

    Parameters

    • orderby: string | object
    • Optional order: string | number | object

    Returns default<T>

  • Update all documents.

    Parameters

    Returns Bluebird<any>