Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Items

Package version

Operations for creating new items, and reading/querying all items

see

Item for reading, replacing, or deleting an existing container; use .item(id).

Hierarchy

  • Items

Index

Properties

container

container: Container

The parent container.

Methods

bulk

  • Execute bulk operations on items.

    Bulk takes an array of Operations which are typed based on what the operation does. The choices are: Create, Upsert, Read, Replace, and Delete

    Usage example:

    // partitionKey is optional at the top level if present in the resourceBody const operations: OperationInput[] = [ { operationType: "Create", resourceBody: { id: "doc1", name: "sample", key: "A" } }, { operationType: "Upsert", partitionKey: 'A', resourceBody: { id: "doc2", name: "other", key: "A" } } ]

    await database.container.items.bulk(operation)

    Parameters

    Returns Promise<OperationResponse[]>

changeFeed

create

  • Create an item.

    Any provided type, T, is not necessarily enforced by the SDK. You may get more or less properties and it's up to your logic to enforce it.

    There is no set schema for JSON items. They may contain any number of custom properties.

    Type parameters

    Parameters

    • body: T

      Represents the body of the item. Can contain any number of user defined properties.

    • Default value options: RequestOptions = {}

      Used for modifying the request (for instance, specifying the partition key).

    Returns Promise<ItemResponse<T>>

query

  • Queries all items.

    example

    Read all items to array.

    const querySpec: SqlQuerySpec = {
      query: "SELECT * FROM Families f WHERE f.lastName = @lastName",
      parameters: [
        {name: "@lastName", value: "Hendricks"}
      ]
    };
    const {result: items} = await items.query(querySpec).fetchAll();

    Parameters

    • query: string | SqlQuerySpec

      Query configuration for the operation. See SqlQuerySpec for more info on how to configure a query.

    • Optional options: FeedOptions

      Used for modifying the request (for instance, specifying the partition key).

    Returns QueryIterator<any>

  • Queries all items.

    example

    Read all items to array.

    const querySpec: SqlQuerySpec = {
      query: "SELECT firstname FROM Families f WHERE f.lastName = @lastName",
      parameters: [
        {name: "@lastName", value: "Hendricks"}
      ]
    };
    const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll();

    Type parameters

    • T

    Parameters

    • query: string | SqlQuerySpec

      Query configuration for the operation. See SqlQuerySpec for more info on how to configure a query.

    • Optional options: FeedOptions

      Used for modifying the request (for instance, specifying the partition key).

    Returns QueryIterator<T>

readAll

readChangeFeed

upsert

Generated using TypeDoc