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

  • Read all items.

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

    example

    Read all items to array.

    const {body: containerList} = await items.readAll().fetchAll();

    Parameters

    • Optional options: FeedOptions

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

    Returns QueryIterator<ItemDefinition>

  • Read all items.

    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.

    example

    Read all items to array.

    const {body: containerList} = await items.readAll().fetchAll();

    Type parameters

    Parameters

    • Optional options: FeedOptions

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

    Returns QueryIterator<T>

readChangeFeed

  • Create a ChangeFeedIterator to iterate over pages of changes

    deprecated

    Use changeFeed instead.

    example

    Read from the beginning of the change feed.

    const iterator = items.readChangeFeed({ startFromBeginning: true });
    const firstPage = await iterator.fetchNext();
    const firstPageResults = firstPage.result
    const secondPage = await iterator.fetchNext();

    Parameters

    • partitionKey: string | number | boolean
    • Optional changeFeedOptions: ChangeFeedOptions

    Returns ChangeFeedIterator<any>

  • Create a ChangeFeedIterator to iterate over pages of changes

    deprecated

    Use changeFeed instead.

    Parameters

    Returns ChangeFeedIterator<any>

  • Create a ChangeFeedIterator to iterate over pages of changes

    deprecated

    Use changeFeed instead.

    Type parameters

    • T

    Parameters

    • partitionKey: string | number | boolean
    • Optional changeFeedOptions: ChangeFeedOptions

    Returns ChangeFeedIterator<T>

  • Create a ChangeFeedIterator to iterate over pages of changes

    deprecated

    Use changeFeed instead.

    Type parameters

    • T

    Parameters

    Returns ChangeFeedIterator<T>

upsert

  • Upsert an item.

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

    Parameters

    • body: any

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

    • Optional options: RequestOptions

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

    Returns Promise<ItemResponse<ItemDefinition>>

  • Upsert 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.

    • Optional options: RequestOptions

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

    Returns Promise<ItemResponse<T>>

Generated using TypeDoc