Interface Table

Table is a simple document store for persistent application backend storage.

let table = new Table("my-table");
await table.insert({id: "kuibai", data: 42});
let item = await table.get({id: "kuibai"});

Tables support a single primary key with a user-defined name and type. All other document properties are schemaless. If not specified, a primary key named id with type string is used.

All queries provide a subset of properties to filter on, and only filters on value equality are supported. The get, update and delete operations expect the query to contain only the value for the primary key.

interface Table {
    primaryKey: Output<string>;
    primaryKeyType: Output<string>;
    delete(query): Promise<void>;
    get(query): Promise<any>;
    insert(item): Promise<void>;
    scan(): Promise<any[]>;
    scan(callback): Promise<void>;
    update(query, updates): Promise<void>;
}

Properties

primaryKey: Output<string>

The name of the primary key.

primaryKeyType: Output<string>

The type of the primary key.

Methods

  • Deletes a documents from the table.

    Parameters

    • query: Object

      An object with the primary key ("id" by default) assigned the value to lookup.

    Returns Promise<void>

    A promise for the success or failure of the delete.

  • Get a document from the table.

    Parameters

    • query: Object

      An object with the primary key ("id" by default) assigned the value to lookup.

    Returns Promise<any>

    A promise for the resulting document if found, or for undefined if not found, or a failed promise if the query could not be processed.

  • Insert a document into the table.

    Parameters

    • item: Object

      An object representing the full document to insert. Must include a property for the primary key ("id" by default).

    Returns Promise<void>

    A promise for the success or failure of the insert.

  • Gets all documents from the table.

    Returns Promise<any[]>

    A promise for the resulting documents, or a failed promise if the lookup fails.

  • Parameters

    • callback: ((items) => Promise<boolean>)
        • (items): Promise<boolean>
        • Parameters

          • items: any[]

          Returns Promise<boolean>

    Returns Promise<void>

  • Updates a documents in the table.

    Parameters

    • query: Object

      An object with the primary key ("id" by default) assigned the value to lookup.

    • updates: Object

      An object with all document properties that should be updated.

    Returns Promise<void>

    A promise for the success or failure of the update.

Generated using TypeDoc