Class DocumentsClient<DocumentType>

SDK for interacting with documents in AppDB.

Example Usage

import { AppDBClient } from '@domoinc/toolkit';

interface Context {
name: string;
age: number;
}
const appDbClient = new AppDBClient.DocumentsClient<Context>('collectionName');

const addRecord = async (name: string, age: number) =>
appDbClient.create({ name, age });

Type Parameters

  • DocumentType

Hierarchy

  • DocumentsClient

Constructors

  • Type Parameters

    • DocumentType

    Parameters

    • collection: string
    • Optional typeguard: TypeGuard<DocumentType>
    • Optional reCaptchaToken: string

    Returns DocumentsClient<DocumentType>

Properties

collection: string
reCaptchaHeader: {
    X-DOMO-Ryuu-Recaptcha?: string;
}

Type declaration

  • Optional X-DOMO-Ryuu-Recaptcha?: string
transportClient: TransportClientClass
typeguard?: TypeGuard<DocumentType>

Include if using arrays as document types

Methods

  • A helper method to create new documents in the collection

    Parameters

    • documents: DocumentType | DocumentType[]

    Returns Promise<Response<AppDBDocument<DocumentType>>>

  • A helper method to remove one or more documents from the collection

    Parameters

    • documents: string

    Returns Promise<Response<void>>

  • Parameters

    • documents: string[]

    Returns Promise<Response<AppDBBulkDeleteResponse>>

  • A helper method to retrieve the documents in the initialized collection

    Type Parameters

    • T = AppDBDocument<DocumentType>[]

    Parameters

    • Optional query: FilterQuery<DocumentType>

      Used to determine which documents are included in the results

    • Optional queryParams: {
          avg?: string[];
          count?: string;
          groupby?: string[];
          limit?: number;
          max?: string[];
          min?: string[];
          offset?: number;
          orderby?: string[];
          sum?: string[];
          [key: string]: string | number | string[] | undefined;
      }
      • [key: string]: string | number | string[] | undefined
      • Optional avg?: string[]
      • Optional count?: string
      • Optional groupby?: string[]
      • Optional limit?: number
      • Optional max?: string[]
      • Optional min?: string[]
      • Optional offset?: number
      • Optional orderby?: string[]
      • Optional sum?: string[]

    Returns Promise<Response<T>>

  • Parameters

    • x: DocumentType | DocumentType[]

    Returns x is DocumentType[]

  • A helper method to update all documents matching the given query with the given operation.

    Parameters

    • query: FilterQuery<DocumentType>

      Query used to determine which documents are affected by the update

    • operation: UpdateQuery<DocumentType>

      mongodb UpdateQuery operation to be applied on the matching documents

    Returns Promise<Response<number>>

  • A helper method to update one or more existing documents in the collection

    Parameters

    • documents: AppDBUpdatedDocument<DocumentType>

    Returns Promise<Response<AppDBDocument<DocumentType>>>

  • Parameters

    • documents: AppDBUpdatedDocument<DocumentType>[]

    Returns Promise<Response<AppDBBulkUpdateResponse>>

Generated using TypeDoc