Class DataAccessObject

Data Access object.

Hierarchy

  • DataAccessObject

Constructors

  • DAO constructor.

    Parameters

    • source: string

      Data source

    • table: string

      Table name

    • pk: string

      Private key name

    • row: any

    Returns DataAccessObject

Properties

original: any
pk: string
ref: any
source: string
table: string

Methods

  • Parameters

    • row: any

    Returns void

  • Deletes the document.

    Returns

    True if deleted, false if not deleted

    Returns Promise<boolean>

  • Atomic increment

    Parameters

    • field: string

      Name of the field

    • inc: number

      Amount to increment

    Returns Promise<void>

  • Inserts the document.

    Returns Promise<void>

  • Saves the document changes.

    Returns

    True if saved, false if not saved

    Parameters

    • Optional condition: DataFilter<any>

      Optional. Condition to check before updating.

    Returns Promise<boolean>

  • Deletes rows

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • filter: GenericFilter

      Filter to apply

    Returns Promise<number>

  • Finds rows

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • filter: GenericFilter

      Filter to apply

    • sortBy: string

      Sort results by this field. Leave as null for default sorting

    • sortDir: SortDirection

      "asc" or "desc". Leave as null for default sorting

    • skip: number

      Number of rows to skip. Leave as -1 for no skip

    • limit: number

      Limit of results. Leave as -1 for no limit

    • projection: Set<string>

      List of fields to fetch from the table. Leave as null to fetch them all.

    • queryExtraOptions: QueryExtraOptions

      Additional query options

    Returns Promise<any[]>

  • Finds by primary key

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • keyName: string

      Key name

    • keyValue: any

      Key value

    Returns Promise<any>

  • Finds rows (stream) / Async

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • filter: GenericFilter

      Filter to apply

    • sortBy: string

      Sort results by this field. Leave as null for default sorting

    • sortDir: SortDirection

      "asc" or "desc". Leave as null for default sorting

    • skip: number

      Number of rows to skip. Leave as -1 for no skip

    • limit: number

      Limit of results. Leave as -1 for no limit

    • projection: Set<string>

      List of fields to fetch from the table. Leave as null to fetch them all.

    • queryExtraOptions: QueryExtraOptions

      Additional query options

    • each: ((row: any) => Promise<void>)

      Function to parse each row

        • (row: any): Promise<void>
        • Parameters

          • row: any

          Returns Promise<void>

    Returns Promise<void>

  • Finds rows (stream) / Sync

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • filter: GenericFilter

      Filter to apply

    • sortBy: string

      Sort results by this field. Leave as null for default sorting

    • sortDir: SortDirection

      "asc" or "desc". Leave as null for default sorting

    • skip: number

      Number of rows to skip. Leave as -1 for no skip

    • limit: number

      Limit of results. Leave as -1 for no limit

    • projection: Set<string>

      List of fields to fetch from the table. Leave as null to fetch them all.

    • queryExtraOptions: QueryExtraOptions

      Additional query options

    • each: ((row: any) => void)

      Function to parse each row

        • (row: any): void
        • Parameters

          • row: any

          Returns void

    Returns Promise<void>

  • Atomic increment

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • keyName: string

      Key name

    • keyValue: any

      Key value

    • prop: string

      Field to increment

    • inc: number

      Amount to increment

    Returns Promise<void>

  • Insert instance

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • row: any

      Row to insert

    Returns Promise<void>

  • Insert instances

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • rows: any[]

      Rows to insert

    Returns Promise<void>

  • Aggregation

    Parameters

    • source: string

      Data source name

    • table: string

      Table name

    • filter: GenericFilter

      Filter to apply

    • id: string

      Primary Key name

    • field: string

      Field to aggregate

    Returns Promise<number>

Generated using TypeDoc