Options
All
  • Public
  • Public/Protected
  • All
Menu

Base class for bridge stores.

Hierarchy

Index

Constructors

constructor

Properties

Readonly db

db: Nedb<any>

Methods

convertTo

  • convertTo<T, O>(func: (input: T) => O): (doc: T) => O
  • Convenience method to convert a document to something.

    Type parameters

    • T

    • O

    Parameters

    • func: (input: T) => O

      The function which will be called with a single document object. Guaranteed not to be null.

        • (input: T): O
        • Parameters

          • input: T

          Returns O

    Returns (doc: T) => O

    A transformFn function to pass to the standard select/delete/upsert/etc methods.

      • (doc: T): O
      • Parameters

        • doc: T

        Returns O

delete

  • delete(query: Record<string, unknown>): Promise<number>

insert

  • insert(objects: unknown): Promise<any[]>

insertIfNotExists

  • insertIfNotExists(query: Record<string, unknown>, insertObj: Record<string, unknown>): Promise<void>
  • INSERT IF NOT EXISTS a single document

    Parameters

    • query: Record<string, unknown>
    • insertObj: Record<string, unknown>

    Returns Promise<void>

select

  • select<T, O>(query: Record<string, unknown>, transformFn?: (input: T) => O): Promise<O[]>
  • SELECT a number of documents.

    Type parameters

    • T

    • O

    Parameters

    • query: Record<string, unknown>
    • Optional transformFn: (input: T) => O
        • (input: T): O
        • Parameters

          • input: T

          Returns O

    Returns Promise<O[]>

selectOne

  • selectOne<T, O>(query: Record<string, unknown>, transformFn?: (input: T) => O): Promise<null | O>
  • SELECT a single document.

    Type parameters

    • T

    • O

    Parameters

    • query: Record<string, unknown>
    • Optional transformFn: (input: T) => O
        • (input: T): O
        • Parameters

          • input: T

          Returns O

    Returns Promise<null | O>

setUnique

  • setUnique(fieldName: string, sparse?: boolean): void
  • Set a UNIQUE key constraint on the given field.

    Parameters

    • fieldName: string

      The field name. Use dot notation for nested objects.

    • sparse: boolean = false

      Allow sparse entries (undefined won't cause a key violation).

    Returns void

update

  • update(query: Record<string, unknown>, updateVals: Record<string, unknown>): Promise<void>
  • UPDATE a single document. If the document already exists, this will NOT update it.

    Parameters

    • query: Record<string, unknown>
    • updateVals: Record<string, unknown>

    Returns Promise<void>

upsert

  • upsert<T>(query: Record<string, unknown>, updateVals: T): Promise<void>
  • UPSERT a single document

    Type parameters

    • T

    Parameters

    • query: Record<string, unknown>
    • updateVals: T

    Returns Promise<void>

Generated using TypeDoc