@azure/cosmos

  • Version 4.0.0
  • Published
  • 3.9 MB
  • 13 dependencies
  • MIT license

Install

npm i @azure/cosmos
yarn add @azure/cosmos
pnpm add @azure/cosmos

Overview

Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API

Index

Variables

Functions

Classes

Interfaces

Enums

Type Aliases

Variables

variable BulkOperationType

const BulkOperationType: {
readonly Create: 'Create';
readonly Upsert: 'Upsert';
readonly Read: 'Read';
readonly Delete: 'Delete';
readonly Replace: 'Replace';
readonly Patch: 'Patch';
};

    variable Constants

    const Constants: {
    HttpHeaders: {
    Authorization: string;
    ETag: string;
    MethodOverride: string;
    Slug: string;
    ContentType: string;
    LastModified: string;
    ContentEncoding: string;
    CharacterSet: string;
    UserAgent: string;
    IfModifiedSince: string;
    IfMatch: string;
    IfNoneMatch: string;
    ContentLength: string;
    AcceptEncoding: string;
    KeepAlive: string;
    CacheControl: string;
    TransferEncoding: string;
    ContentLanguage: string;
    ContentLocation: string;
    ContentMd5: string;
    ContentRange: string;
    Accept: string;
    AcceptCharset: string;
    AcceptLanguage: string;
    IfRange: string;
    IfUnmodifiedSince: string;
    MaxForwards: string;
    ProxyAuthorization: string;
    AcceptRanges: string;
    ProxyAuthenticate: string;
    RetryAfter: string;
    SetCookie: string;
    WwwAuthenticate: string;
    Origin: string;
    Host: string;
    AccessControlAllowOrigin: string;
    AccessControlAllowHeaders: string;
    KeyValueEncodingFormat: string;
    WrapAssertionFormat: string;
    WrapAssertion: string;
    WrapScope: string;
    SimpleToken: string;
    HttpDate: string;
    Prefer: string;
    Location: string;
    Referer: string;
    A_IM: string;
    Query: string;
    IsQuery: string;
    IsQueryPlan: string;
    SupportedQueryFeatures: string;
    QueryVersion: string;
    Continuation: string;
    ContinuationToken: string;
    PageSize: string;
    ItemCount: string;
    ActivityId: string;
    PreTriggerInclude: string;
    PreTriggerExclude: string;
    PostTriggerInclude: string;
    PostTriggerExclude: string;
    IndexingDirective: string;
    SessionToken: string;
    ConsistencyLevel: string;
    XDate: string;
    CollectionPartitionInfo: string;
    CollectionServiceInfo: string;
    RetryAfterInMilliseconds: string;
    RetryAfterInMs: string;
    IsFeedUnfiltered: string;
    ResourceTokenExpiry: string;
    EnableScanInQuery: string;
    EmitVerboseTracesInQuery: string;
    EnableCrossPartitionQuery: string;
    ParallelizeCrossPartitionQuery: string;
    ResponseContinuationTokenLimitInKB: string;
    PopulateQueryMetrics: string;
    QueryMetrics: string;
    PopulateIndexMetrics: string;
    IndexUtilization: string;
    Version: string;
    OwnerFullName: string;
    OwnerId: string;
    PartitionKey: string;
    PartitionKeyRangeID: string;
    StartEpk: string;
    EndEpk: string;
    ReadFeedKeyType: string;
    MaxEntityCount: string;
    CurrentEntityCount: string;
    CollectionQuotaInMb: string;
    CollectionCurrentUsageInMb: string;
    MaxMediaStorageUsageInMB: string;
    CurrentMediaStorageUsageInMB: string;
    RequestCharge: string;
    PopulateQuotaInfo: string;
    MaxResourceQuota: string;
    OfferType: string;
    OfferThroughput: string;
    AutoscaleSettings: string;
    DisableRUPerMinuteUsage: string;
    IsRUPerMinuteUsed: string;
    OfferIsRUPerMinuteThroughputEnabled: string;
    IndexTransformationProgress: string;
    LazyIndexingProgress: string;
    IsUpsert: string;
    SubStatus: string;
    EnableScriptLogging: string;
    ScriptLogResults: string;
    ALLOW_MULTIPLE_WRITES: string;
    IsBatchRequest: string;
    IsBatchAtomic: string;
    BatchContinueOnError: string;
    DedicatedGatewayPerRequestCacheStaleness: string;
    ForceRefresh: string;
    PriorityLevel: string;
    };
    WritableLocations: string;
    ReadableLocations: string;
    LocationUnavailableExpirationTimeInMs: number;
    ENABLE_MULTIPLE_WRITABLE_LOCATIONS: string;
    DefaultUnavailableLocationExpirationTimeMS: number;
    ThrottleRetryCount: string;
    ThrottleRetryWaitTimeInMs: string;
    CurrentVersion: string;
    AzureNamespace: string;
    AzurePackageName: string;
    SDKName: string;
    SDKVersion: string;
    CosmosDbDiagnosticLevelEnvVarName: string;
    DefaultMaxBulkRequestBodySizeInBytes: number;
    Quota: { CollectionSize: string };
    Path: {
    Root: string;
    DatabasesPathSegment: string;
    CollectionsPathSegment: string;
    UsersPathSegment: string;
    DocumentsPathSegment: string;
    PermissionsPathSegment: string;
    StoredProceduresPathSegment: string;
    TriggersPathSegment: string;
    UserDefinedFunctionsPathSegment: string;
    ConflictsPathSegment: string;
    AttachmentsPathSegment: string;
    PartitionKeyRangesPathSegment: string;
    SchemasPathSegment: string;
    OffersPathSegment: string;
    TopologyPathSegment: string;
    DatabaseAccountPathSegment: string;
    };
    PartitionKeyRange: PartitionKeyRangePropertiesNames;
    QueryRangeConstants: { MinInclusive: string; MaxExclusive: string; min: string };
    EffectiveParitionKeyConstants: {
    MinimumInclusiveEffectivePartitionKey: string;
    MaximumExclusiveEffectivePartitionKey: string;
    };
    EffectivePartitionKeyConstants: {
    MinimumInclusiveEffectivePartitionKey: string;
    MaximumExclusiveEffectivePartitionKey: string;
    };
    };

    variable DEFAULT_PARTITION_KEY_PATH

    const DEFAULT_PARTITION_KEY_PATH: string;

      variable PatchOperationType

      const PatchOperationType: {
      readonly add: 'add';
      readonly replace: 'replace';
      readonly remove: 'remove';
      readonly set: 'set';
      readonly incr: 'incr';
      };

        variable QueryMetricsConstants

        const QueryMetricsConstants: {
        RetrievedDocumentCount: string;
        RetrievedDocumentSize: string;
        OutputDocumentCount: string;
        OutputDocumentSize: string;
        IndexHitRatio: string;
        IndexHitDocumentCount: string;
        TotalQueryExecutionTimeInMs: string;
        QueryCompileTimeInMs: string;
        LogicalPlanBuildTimeInMs: string;
        PhysicalPlanBuildTimeInMs: string;
        QueryOptimizationTimeInMs: string;
        IndexLookupTimeInMs: string;
        DocumentLoadTimeInMs: string;
        VMExecutionTimeInMs: string;
        DocumentWriteTimeInMs: string;
        QueryEngineTimes: string;
        SystemFunctionExecuteTimeInMs: string;
        UserDefinedFunctionExecutionTimeInMs: string;
        RetrievedDocumentCountText: string;
        RetrievedDocumentSizeText: string;
        OutputDocumentCountText: string;
        OutputDocumentSizeText: string;
        IndexUtilizationText: string;
        TotalQueryExecutionTimeText: string;
        QueryPreparationTimesText: string;
        QueryCompileTimeText: string;
        LogicalPlanBuildTimeText: string;
        PhysicalPlanBuildTimeText: string;
        QueryOptimizationTimeText: string;
        QueryEngineTimesText: string;
        IndexLookupTimeText: string;
        DocumentLoadTimeText: string;
        WriteOutputTimeText: string;
        RuntimeExecutionTimesText: string;
        TotalExecutionTimeText: string;
        SystemFunctionExecuteTimeText: string;
        UserDefinedFunctionExecutionTimeText: string;
        ClientSideQueryMetricsText: string;
        RetriesText: string;
        RequestChargeText: string;
        FetchExecutionRangesText: string;
        SchedulingMetricsText: string;
        };

          variable StatusCodes

          const StatusCodes: StatusCodesType;

          Functions

          function createAuthorizationSasToken

          createAuthorizationSasToken: (
          masterKey: string,
          sasTokenProperties: SasTokenProperties
          ) => Promise<string>;
          • Experimental internal only Generates the payload representing the permission configuration for the sas token.

          function setAuthorizationTokenHeaderUsingMasterKey

          setAuthorizationTokenHeaderUsingMasterKey: (
          verb: HTTPMethod,
          resourceId: string,
          resourceType: ResourceType,
          headers: CosmosHeaders,
          masterKey: string
          ) => Promise<void>;
          • The default function for setting header token using the masterKey

          Classes

          class ChangeFeedIterator

          class ChangeFeedIterator<T> {}
          • Provides iterator for change feed.

            Use Items.changeFeed() to get an instance of the iterator.

          property hasMoreResults

          readonly hasMoreResults: boolean;
          • Gets a value indicating whether there are potentially additional results that can be retrieved.

            Initially returns true. This value is set based on whether the last execution returned a continuation token.

            Returns

            Boolean value representing if whether there are potentially additional results that can be retrieved.

          method fetchNext

          fetchNext: () => Promise<ChangeFeedResponse<Array<T & Resource>>>;
          • Read feed and retrieves the next page of results in Azure Cosmos DB.

          method getAsyncIterator

          getAsyncIterator: () => AsyncIterable<ChangeFeedResponse<Array<T & Resource>>>;
          • Gets an async iterator which will yield pages of results from Azure Cosmos DB.

          class ChangeFeedIteratorResponse

          class ChangeFeedIteratorResponse<T> {}
          • A single response page from the Azure Cosmos DB Change Feed

          property activityId

          readonly activityId: string;
          • Gets the activity ID for the request from the Azure Cosmos DB service.

          property continuationToken

          readonly continuationToken: string;
          • Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.

          property count

          readonly count: number;
          • Gets the number of items returned in the response from Azure Cosmos DB

          property diagnostics

          readonly diagnostics: CosmosDiagnostics;
          • Cosmos Diagnostic Object.

          property headers

          headers: CosmosHeaders;
          • Response headers of the response from Azure Cosmos DB

          property requestCharge

          readonly requestCharge: number;
          • Gets the request charge for this request from the Azure Cosmos DB service.

          property result

          readonly result: {};
          • Gets the items returned in the response from Azure Cosmos DB

          property sessionToken

          readonly sessionToken: string;
          • Gets the session token for use in session consistency reads from the Azure Cosmos DB service.

          property statusCode

          readonly statusCode: number;
          • Gets the status code of the response from Azure Cosmos DB

          property subStatusCode

          readonly subStatusCode?: number;
          • Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone.

          class ChangeFeedResponse

          class ChangeFeedResponse<T> {}
          • A single response page from the Azure Cosmos DB Change Feed

          property activityId

          readonly activityId: string;
          • Gets the activity ID for the request from the Azure Cosmos DB service.

          property continuation

          readonly continuation: string;
          • Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.

            This is equivalent to the etag property.

          property count

          readonly count: number;
          • Gets the number of items returned in the response from Azure Cosmos DB

          property diagnostics

          readonly diagnostics: CosmosDiagnostics;

            property etag

            readonly etag: string;
            • Gets the entity tag associated with last transaction in the Azure Cosmos DB service, which can be used as If-Non-Match Access condition for ReadFeed REST request or continuation property of ChangeFeedOptions parameter for Items.changeFeed() to get feed changes since the transaction specified by this entity tag.

              This is equivalent to the continuation property.

            property headers

            headers: CosmosHeaders;
            • Response headers of the response from Azure Cosmos DB

            property requestCharge

            readonly requestCharge: number;
            • Gets the request charge for this request from the Azure Cosmos DB service.

            property result

            readonly result: {};
            • Gets the items returned in the response from Azure Cosmos DB

            property sessionToken

            readonly sessionToken: string;
            • Gets the session token for use in session consistency reads from the Azure Cosmos DB service.

            property statusCode

            readonly statusCode: number;
            • Gets the status code of the response from Azure Cosmos DB

            class ChangeFeedStartFrom

            abstract class ChangeFeedStartFrom {}
            • Base class for where to start a ChangeFeedIterator.

            method Beginning

            static Beginning: (
            cfResource?: PartitionKey | FeedRange
            ) => ChangeFeedStartFromBeginning;
            • Returns an object that tells the ChangeFeedIterator to start from the beginning of time.

              Parameter cfResource

              PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.

            method Continuation

            static Continuation: (
            continuationToken: string
            ) => ChangeFeedStartFromContinuation;
            • Returns an object that tells the ChangeFeedIterator to start reading changes from a save point.

              Parameter continuation

              The continuation to resume from.

            method Now

            static Now: (cfResource?: PartitionKey | FeedRange) => ChangeFeedStartFromNow;
            • Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward.

              Parameter cfResource

              PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.

            method Time

            static Time: (
            startTime: Date,
            cfResource?: PartitionKey | FeedRange
            ) => ChangeFeedStartFromTime;
            • Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward.

              Parameter startTime

              Date object specfiying the time to start reading changes from.

              Parameter cfResource

              PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.

            class ClientContext

            class ClientContext {}

            constructor

            constructor(
            cosmosClientOptions: CosmosClientOptions,
            globalEndpointManager: GlobalEndpointManager,
            clientConfig: ClientConfigDiagnostic,
            diagnosticLevel: CosmosDbDiagnosticLevel
            );

              property diagnosticLevel

              diagnosticLevel: CosmosDbDiagnosticLevel;

                property partitionKeyDefinitionCache

                partitionKeyDefinitionCache: { [containerUrl: string]: any };

                  method batch

                  batch: <T>({
                  body,
                  path,
                  partitionKey,
                  resourceId,
                  options,
                  diagnosticNode,
                  }: {
                  body: T;
                  path: string;
                  partitionKey: PartitionKey;
                  resourceId: string;
                  options?: RequestOptions;
                  diagnosticNode: DiagnosticNodeInternal;
                  }) => Promise<Response_2<any>>;

                    method bulk

                    bulk: <T>({
                    body,
                    path,
                    partitionKeyRangeId,
                    resourceId,
                    bulkOptions,
                    options,
                    diagnosticNode,
                    }: {
                    body: T;
                    path: string;
                    partitionKeyRangeId: string;
                    resourceId: string;
                    bulkOptions?: BulkOptions;
                    options?: RequestOptions;
                    diagnosticNode: DiagnosticNodeInternal;
                    }) => Promise<Response_2<any>>;

                      method clearSessionToken

                      clearSessionToken: (path: string) => void;

                        method create

                        create: <T, U = T>({
                        body,
                        path,
                        resourceType,
                        resourceId,
                        diagnosticNode,
                        options,
                        partitionKey,
                        }: {
                        body: T;
                        path: string;
                        resourceType: ResourceType;
                        resourceId: string;
                        diagnosticNode: DiagnosticNodeInternal;
                        options?: RequestOptions;
                        partitionKey?: PartitionKey;
                        }) => Promise<Response_2<T & U & Resource>>;

                          method delete

                          delete: <T>({
                          path,
                          resourceType,
                          resourceId,
                          options,
                          partitionKey,
                          method,
                          diagnosticNode,
                          }: {
                          path: string;
                          resourceType: ResourceType;
                          resourceId: string;
                          options?: RequestOptions;
                          partitionKey?: PartitionKey;
                          method?: HTTPMethod;
                          diagnosticNode: DiagnosticNodeInternal;
                          }) => Promise<Response_2<T & Resource>>;

                            method execute

                            execute: <T>({
                            sprocLink,
                            params,
                            options,
                            partitionKey,
                            diagnosticNode,
                            }: {
                            sprocLink: string;
                            params?: any[];
                            options?: RequestOptions;
                            partitionKey?: PartitionKey;
                            diagnosticNode: DiagnosticNodeInternal;
                            }) => Promise<Response_2<T>>;

                              method getClientConfig

                              getClientConfig: () => ClientConfigDiagnostic;

                                method getDatabaseAccount

                                getDatabaseAccount: (
                                diagnosticNode: DiagnosticNodeInternal,
                                options?: RequestOptions
                                ) => Promise<Response_2<DatabaseAccount>>;
                                • Gets the Database account information.

                                  Parameter options

                                  urlConnection in the options is the endpoint url whose database account needs to be retrieved. If not present, current client's url will be used.

                                method getQueryPlan

                                getQueryPlan: (
                                path: string,
                                resourceType: ResourceType,
                                resourceId: string,
                                query: SqlQuerySpec | string,
                                options: FeedOptions,
                                diagnosticNode: DiagnosticNodeInternal
                                ) => Promise<Response_2<PartitionedQueryExecutionInfo>>;

                                  method getReadEndpoint

                                  getReadEndpoint: (diagnosticNode: DiagnosticNodeInternal) => Promise<string>;

                                    method getReadEndpoints

                                    getReadEndpoints: () => Promise<readonly string[]>;

                                      method getWriteEndpoint

                                      getWriteEndpoint: (diagnosticNode: DiagnosticNodeInternal) => Promise<string>;

                                        method getWriteEndpoints

                                        getWriteEndpoints: () => Promise<readonly string[]>;

                                          method initializeDiagnosticSettings

                                          initializeDiagnosticSettings: (diagnosticLevel: CosmosDbDiagnosticLevel) => void;

                                            method patch

                                            patch: <T>({
                                            body,
                                            path,
                                            resourceType,
                                            resourceId,
                                            options,
                                            partitionKey,
                                            diagnosticNode,
                                            }: {
                                            body: any;
                                            path: string;
                                            resourceType: ResourceType;
                                            resourceId: string;
                                            options?: RequestOptions;
                                            partitionKey?: PartitionKey;
                                            diagnosticNode: DiagnosticNodeInternal;
                                            }) => Promise<Response_2<T & Resource>>;

                                              method queryFeed

                                              queryFeed: <T>({
                                              path,
                                              resourceType,
                                              resourceId,
                                              resultFn,
                                              query,
                                              options,
                                              diagnosticNode,
                                              partitionKeyRangeId,
                                              partitionKey,
                                              startEpk,
                                              endEpk,
                                              }: {
                                              path: string;
                                              resourceType: ResourceType;
                                              resourceId: string;
                                              resultFn: (result: { [key: string]: any }) => any[];
                                              query: SqlQuerySpec | string;
                                              options: FeedOptions;
                                              diagnosticNode: DiagnosticNodeInternal;
                                              partitionKeyRangeId?: string;
                                              partitionKey?: PartitionKey;
                                              startEpk?: string | undefined;
                                              endEpk?: string | undefined;
                                              }) => Promise<Response_2<T & Resource>>;

                                                method queryPartitionKeyRanges

                                                queryPartitionKeyRanges: (
                                                collectionLink: string,
                                                query?: string | SqlQuerySpec,
                                                options?: FeedOptions
                                                ) => QueryIterator<PartitionKeyRange>;

                                                  method read

                                                  read: <T>({
                                                  path,
                                                  resourceType,
                                                  resourceId,
                                                  options,
                                                  partitionKey,
                                                  diagnosticNode,
                                                  }: {
                                                  path: string;
                                                  resourceType: ResourceType;
                                                  resourceId: string;
                                                  options?: RequestOptions;
                                                  partitionKey?: PartitionKey;
                                                  diagnosticNode: DiagnosticNodeInternal;
                                                  }) => Promise<Response_2<T & Resource>>;

                                                  method recordDiagnostics

                                                  recordDiagnostics: (diagnostic: CosmosDiagnostics) => void;

                                                    method replace

                                                    replace: <T>({
                                                    body,
                                                    path,
                                                    resourceType,
                                                    resourceId,
                                                    options,
                                                    partitionKey,
                                                    diagnosticNode,
                                                    }: {
                                                    body: any;
                                                    path: string;
                                                    resourceType: ResourceType;
                                                    resourceId: string;
                                                    options?: RequestOptions;
                                                    partitionKey?: PartitionKey;
                                                    diagnosticNode: DiagnosticNodeInternal;
                                                    }) => Promise<Response_2<T & Resource>>;

                                                      method upsert

                                                      upsert: <T, U = T>({
                                                      body,
                                                      path,
                                                      resourceType,
                                                      resourceId,
                                                      options,
                                                      partitionKey,
                                                      diagnosticNode,
                                                      }: {
                                                      body: T;
                                                      path: string;
                                                      resourceType: ResourceType;
                                                      resourceId: string;
                                                      options?: RequestOptions;
                                                      partitionKey?: PartitionKey;
                                                      diagnosticNode: DiagnosticNodeInternal;
                                                      }) => Promise<Response_2<T & U & Resource>>;

                                                        class ClientSideMetrics

                                                        class ClientSideMetrics {}

                                                          constructor

                                                          constructor(requestCharge: number);

                                                            property requestCharge

                                                            readonly requestCharge: number;

                                                              property zero

                                                              static readonly zero: ClientSideMetrics;

                                                                method add

                                                                add: (...clientSideMetricsArray: ClientSideMetrics[]) => ClientSideMetrics;
                                                                • Adds one or more ClientSideMetrics to a copy of this instance and returns the result.

                                                                method createFromArray

                                                                static createFromArray: (
                                                                ...clientSideMetricsArray: ClientSideMetrics[]
                                                                ) => ClientSideMetrics;

                                                                  class Conflict

                                                                  class Conflict {}
                                                                  • Use to read or delete a given Conflict by id.

                                                                    See Also

                                                                  constructor

                                                                  constructor(
                                                                  container: Container,
                                                                  id: string,
                                                                  clientContext: ClientContext,
                                                                  partitionKey?: PartitionKey
                                                                  );

                                                                  property container

                                                                  readonly container: Container;

                                                                    property id

                                                                    readonly id: string;

                                                                      property url

                                                                      readonly url: string;
                                                                      • Returns a reference URL to the resource. Used for linking in Permissions.

                                                                      method delete

                                                                      delete: (options?: RequestOptions) => Promise<ConflictResponse>;

                                                                      method read

                                                                      read: (options?: RequestOptions) => Promise<ConflictResponse>;

                                                                      class ConflictResponse

                                                                      class ConflictResponse extends ResourceResponse<ConflictDefinition & Resource> {}

                                                                        constructor

                                                                        constructor(
                                                                        resource: ConflictDefinition & Resource,
                                                                        headers: CosmosHeaders,
                                                                        statusCode: number,
                                                                        conflict: Conflict,
                                                                        diagnostics: CosmosDiagnostics
                                                                        );

                                                                          property conflict

                                                                          readonly conflict: Conflict;

                                                                          class Conflicts

                                                                          class Conflicts {}
                                                                          • Use to query or read all conflicts.

                                                                            See Also

                                                                          constructor

                                                                          constructor(container: Container, clientContext: ClientContext);

                                                                            property container

                                                                            readonly container: Container;

                                                                              method query

                                                                              query: {
                                                                              (query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
                                                                              <T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
                                                                              };
                                                                              • Queries all conflicts.

                                                                                Parameter query

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

                                                                                Parameter options

                                                                                Use to set options like response page size, continuation tokens, etc.

                                                                                Returns

                                                                                QueryIterator Allows you to return results in an array or iterate over them one at a time.

                                                                              • Queries all conflicts.

                                                                                Parameter query

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

                                                                                Parameter options

                                                                                Use to set options like response page size, continuation tokens, etc.

                                                                                Returns

                                                                                QueryIterator Allows you to return results in an array or iterate over them one at a time.

                                                                              method readAll

                                                                              readAll: (options?: FeedOptions) => QueryIterator<ConflictDefinition & Resource>;
                                                                              • Reads all conflicts

                                                                                Parameter options

                                                                                Use to set options like response page size, continuation tokens, etc.

                                                                              class Container

                                                                              class Container {}
                                                                              • Operations for reading, replacing, or deleting a specific, existing container by id.

                                                                                See Also

                                                                                • Containers for creating new containers, and reading/querying all containers; use .containers.

                                                                                  Note: all these operations make calls against a fixed budget. You should design your system such that these calls scale sublinearly with your application. For instance, do not call container(id).read() before every single item.read() call, to ensure the container exists; do this once on application start up.

                                                                              constructor

                                                                              constructor(database: Database, id: string, clientContext: ClientContext);
                                                                              • Returns a container instance. Note: You should get this from database.container(id), rather than creating your own object.

                                                                                Parameter database

                                                                                The parent Database.

                                                                                Parameter id

                                                                                The id of the given container.

                                                                              property conflicts

                                                                              readonly conflicts: Conflicts;
                                                                              • Operations for reading and querying conflicts for the given container.

                                                                                For reading or deleting a specific conflict, use .conflict(id).

                                                                              property database

                                                                              readonly database: Database;

                                                                                property id

                                                                                readonly id: string;

                                                                                  property items

                                                                                  readonly items: Items;
                                                                                  • Operations for creating new items, and reading/querying all items

                                                                                    For reading, replacing, or deleting an existing item, use .item(id).

                                                                                    Example 1

                                                                                    Create a new item

                                                                                    const {body: createdItem} = await container.items.create({id: "<item id>", properties: {}});

                                                                                  property scripts

                                                                                  readonly scripts: Scripts;
                                                                                  • All operations for Stored Procedures, Triggers, and User Defined Functions

                                                                                  property url

                                                                                  readonly url: string;
                                                                                  • Returns a reference URL to the resource. Used for linking in Permissions.

                                                                                  method conflict

                                                                                  conflict: (id: string, partitionKey?: PartitionKey) => Conflict;
                                                                                  • Used to read, replace, or delete a specific, existing Conflict by id.

                                                                                    Use .conflicts for creating new conflicts, or querying/reading all conflicts.

                                                                                    Parameter id

                                                                                    The id of the Conflict.

                                                                                  method delete

                                                                                  delete: (options?: RequestOptions) => Promise<ContainerResponse>;
                                                                                  • Delete the container

                                                                                  method deleteAllItemsForPartitionKey

                                                                                  deleteAllItemsForPartitionKey: (
                                                                                  partitionKey: PartitionKey,
                                                                                  options?: RequestOptions
                                                                                  ) => Promise<ContainerResponse>;
                                                                                  • Delete all documents belong to the container for the provided partition key value

                                                                                    Parameter partitionKey

                                                                                    The partition key value of the items to be deleted

                                                                                  method getFeedRanges

                                                                                  getFeedRanges: () => Promise<ReadonlyArray<FeedRange>>;
                                                                                  • Returns

                                                                                    all the feed ranges for which changefeed could be fetched.

                                                                                  method getPartitionKeyDefinition

                                                                                  getPartitionKeyDefinition: () => Promise<
                                                                                  ResourceResponse<PartitionKeyDefinition>
                                                                                  >;
                                                                                  • Gets the partition key definition first by looking into the cache otherwise by reading the collection.

                                                                                    Deprecated

                                                                                    This method has been renamed to readPartitionKeyDefinition.

                                                                                  method getQueryPlan

                                                                                  getQueryPlan: (
                                                                                  query: string | SqlQuerySpec
                                                                                  ) => Promise<Response_2<PartitionedQueryExecutionInfo>>;

                                                                                    method item

                                                                                    item: (id: string, partitionKeyValue?: PartitionKey) => Item;
                                                                                    • Used to read, replace, or delete a specific, existing Item by id.

                                                                                      Use .items for creating new items, or querying/reading all items.

                                                                                      Parameter id

                                                                                      The id of the Item.

                                                                                      Parameter partitionKeyValue

                                                                                      The value of the Item partition key

                                                                                      Example 1

                                                                                      Replace an item const {body: replacedItem} = await container.item("<item id>", "<partition key value>").replace({id: "<item id>", title: "Updated post", authorID: 5});

                                                                                    method read

                                                                                    read: (options?: RequestOptions) => Promise<ContainerResponse>;
                                                                                    • Read the container's definition

                                                                                    method readInternal

                                                                                    readInternal: (
                                                                                    diagnosticNode: DiagnosticNodeInternal,
                                                                                    options?: RequestOptions
                                                                                    ) => Promise<ContainerResponse>;

                                                                                    method readOffer

                                                                                    readOffer: (options?: RequestOptions) => Promise<OfferResponse>;
                                                                                    • Gets offer on container. If none exists, returns an OfferResponse with undefined.

                                                                                    method readPartitionKeyDefinition

                                                                                    readPartitionKeyDefinition: (
                                                                                    diagnosticNode: DiagnosticNodeInternal
                                                                                    ) => Promise<ResourceResponse<PartitionKeyDefinition>>;
                                                                                    • Gets the partition key definition first by looking into the cache otherwise by reading the collection.

                                                                                    method readPartitionKeyRanges

                                                                                    readPartitionKeyRanges: (
                                                                                    feedOptions?: FeedOptions
                                                                                    ) => QueryIterator<PartitionKeyRange>;

                                                                                      method replace

                                                                                      replace: (
                                                                                      body: ContainerDefinition,
                                                                                      options?: RequestOptions
                                                                                      ) => Promise<ContainerResponse>;
                                                                                      • Replace the container's definition

                                                                                      class ContainerResponse

                                                                                      class ContainerResponse extends ResourceResponse<ContainerDefinition & Resource> {}
                                                                                      • Response object for Container operations

                                                                                      constructor

                                                                                      constructor(
                                                                                      resource: ContainerDefinition & Resource,
                                                                                      headers: CosmosHeaders,
                                                                                      statusCode: number,
                                                                                      container: Container,
                                                                                      diagnostics: CosmosDiagnostics
                                                                                      );

                                                                                        property container

                                                                                        readonly container: Container;

                                                                                        class Containers

                                                                                        class Containers {}
                                                                                        • Operations for creating new containers, and reading/querying all containers

                                                                                          See Also

                                                                                          • Container for reading, replacing, or deleting an existing container; use .container(id).

                                                                                            Note: all these operations make calls against a fixed budget. You should design your system such that these calls scale sublinearly with your application. For instance, do not call containers.readAll() before every single item.read() call, to ensure the container exists; do this once on application start up.

                                                                                        constructor

                                                                                        constructor(database: Database, clientContext: ClientContext);

                                                                                          property database

                                                                                          readonly database: Database;

                                                                                            method create

                                                                                            create: (
                                                                                            body: ContainerRequest,
                                                                                            options?: RequestOptions
                                                                                            ) => Promise<ContainerResponse>;
                                                                                            • Creates a container.

                                                                                              A container is a named logical container for items.

                                                                                              A database may contain zero or more named containers and each container consists of zero or more JSON items.

                                                                                              Being schema-free, the items in a container do not need to share the same structure or fields.

                                                                                              Since containers are application resources, they can be authorized using either the master key or resource keys.

                                                                                              Parameter body

                                                                                              Represents the body of the container.

                                                                                              Parameter options

                                                                                              Use to set options like response page size, continuation tokens, etc.

                                                                                            method createIfNotExists

                                                                                            createIfNotExists: (
                                                                                            body: ContainerRequest,
                                                                                            options?: RequestOptions
                                                                                            ) => Promise<ContainerResponse>;
                                                                                            • Checks if a Container exists, and, if it doesn't, creates it. This will make a read operation based on the id in the body, then if it is not found, a create operation. You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.)

                                                                                              A container is a named logical container for items.

                                                                                              A database may contain zero or more named containers and each container consists of zero or more JSON items.

                                                                                              Being schema-free, the items in a container do not need to share the same structure or fields.

                                                                                              Since containers are application resources, they can be authorized using either the master key or resource keys.

                                                                                              Parameter body

                                                                                              Represents the body of the container.

                                                                                              Parameter options

                                                                                              Use to set options like response page size, continuation tokens, etc.

                                                                                            method createInternal

                                                                                            createInternal: (
                                                                                            diagnosticNode: DiagnosticNodeInternal,
                                                                                            body: ContainerRequest,
                                                                                            options?: RequestOptions
                                                                                            ) => Promise<ContainerResponse>;

                                                                                            method query

                                                                                            query: {
                                                                                            (query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
                                                                                            <T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
                                                                                            };
                                                                                            • Queries all containers.

                                                                                              Parameter query

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

                                                                                              Parameter options

                                                                                              Use to set options like response page size, continuation tokens, etc.

                                                                                              Returns

                                                                                              QueryIterator Allows you to return specific containers in an array or iterate over them one at a time.

                                                                                              Example 1

                                                                                              Read all containers to array.

                                                                                              const querySpec: SqlQuerySpec = {
                                                                                              query: "SELECT * FROM root r WHERE r.id = @container",
                                                                                              parameters: [
                                                                                              {name: "@container", value: "Todo"}
                                                                                              ]
                                                                                              };
                                                                                              const {body: containerList} = await client.database("<db id>").containers.query(querySpec).fetchAll();
                                                                                            • Queries all containers.

                                                                                              Parameter query

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

                                                                                              Parameter options

                                                                                              Use to set options like response page size, continuation tokens, etc.

                                                                                              Returns

                                                                                              QueryIterator Allows you to return specific containers in an array or iterate over them one at a time.

                                                                                              Example 1

                                                                                              Read all containers to array.

                                                                                              const querySpec: SqlQuerySpec = {
                                                                                              query: "SELECT * FROM root r WHERE r.id = @container",
                                                                                              parameters: [
                                                                                              {name: "@container", value: "Todo"}
                                                                                              ]
                                                                                              };
                                                                                              const {body: containerList} = await client.database("<db id>").containers.query(querySpec).fetchAll();

                                                                                            method readAll

                                                                                            readAll: (
                                                                                            options?: FeedOptions
                                                                                            ) => QueryIterator<ContainerDefinition & Resource>;
                                                                                            • Read all containers.

                                                                                              Parameter options

                                                                                              Use to set options like response page size, continuation tokens, etc.

                                                                                              Returns

                                                                                              QueryIterator Allows you to return all containers in an array or iterate over them one at a time.

                                                                                              Example 1

                                                                                              Read all containers to array.

                                                                                              const {body: containerList} = await client.database("<db id>").containers.readAll().fetchAll();

                                                                                            class CosmosClient

                                                                                            class CosmosClient {}
                                                                                            • Provides a client-side logical representation of the Azure Cosmos DB database account. This client is used to configure and execute requests in the Azure Cosmos DB database service.

                                                                                              Example 1

                                                                                              Instantiate a client and create a new database

                                                                                              const client = new CosmosClient({endpoint: "<URL HERE>", auth: {masterKey: "<KEY HERE>"}});
                                                                                              await client.databases.create({id: "<datbase name here>"});

                                                                                              Example 2

                                                                                              Instantiate a client with custom Connection Policy

                                                                                              const connectionPolicy = new ConnectionPolicy();
                                                                                              connectionPolicy.RequestTimeout = 10000;
                                                                                              const client = new CosmosClient({
                                                                                              endpoint: "<URL HERE>",
                                                                                              auth: {masterKey: "<KEY HERE>"},
                                                                                              connectionPolicy
                                                                                              });

                                                                                            constructor

                                                                                            constructor(connectionString: string);
                                                                                            • Creates a new CosmosClient object from a connection string. Your database connection string can be found in the Azure Portal

                                                                                            constructor

                                                                                            constructor(options: CosmosClientOptions);
                                                                                            • Creates a new CosmosClient object. See CosmosClientOptions for more details on what options you can use.

                                                                                              Parameter options

                                                                                              bag of options; require at least endpoint and auth to be configured

                                                                                            property databases

                                                                                            readonly databases: Databases;
                                                                                            • Used for creating new databases, or querying/reading all databases.

                                                                                              Use .database(id) to read, replace, or delete a specific, existing database by id.

                                                                                              Example 1

                                                                                              Create a new database

                                                                                              const {resource: databaseDefinition, database} = await client.databases.create({id: "<name here>"});

                                                                                            property offers

                                                                                            readonly offers: Offers;
                                                                                            • Used for querying & reading all offers.

                                                                                              Use .offer(id) to read, or replace existing offers.

                                                                                            method database

                                                                                            database: (id: string) => Database;
                                                                                            • Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database.

                                                                                              This does not make a network call. Use .read to get info about the database after getting the Database object.

                                                                                              Parameter id

                                                                                              The id of the database.

                                                                                              Example 1

                                                                                              Create a new container off of an existing database

                                                                                              const container = client.database("<database id>").containers.create("<container id>");

                                                                                              Example 2

                                                                                              Delete an existing database

                                                                                              await client.database("<id here>").delete();

                                                                                            method dispose

                                                                                            dispose: () => void;
                                                                                            • Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process.

                                                                                            method getDatabaseAccount

                                                                                            getDatabaseAccount: (
                                                                                            options?: RequestOptions
                                                                                            ) => Promise<ResourceResponse<DatabaseAccount>>;
                                                                                            • Get information about the current DatabaseAccount (including which regions are supported, etc.)

                                                                                            method getDatabaseAccountInternal

                                                                                            getDatabaseAccountInternal: (
                                                                                            diagnosticNode: DiagnosticNodeInternal,
                                                                                            options?: RequestOptions
                                                                                            ) => Promise<ResourceResponse<DatabaseAccount>>;

                                                                                            method getReadEndpoint

                                                                                            getReadEndpoint: () => Promise<string>;
                                                                                            • Gets the currently used read endpoint. Useful for troubleshooting purposes.

                                                                                              The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.

                                                                                            method getReadEndpoints

                                                                                            getReadEndpoints: () => Promise<readonly string[]>;
                                                                                            • Gets the currently used read endpoint. Useful for troubleshooting purposes.

                                                                                              The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.

                                                                                            method getWriteEndpoint

                                                                                            getWriteEndpoint: () => Promise<string>;
                                                                                            • Gets the currently used write endpoint url. Useful for troubleshooting purposes.

                                                                                              The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.

                                                                                            method getWriteEndpoints

                                                                                            getWriteEndpoints: () => Promise<readonly string[]>;
                                                                                            • Gets the known write endpoints. Useful for troubleshooting purposes.

                                                                                              The urls may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.

                                                                                            method offer

                                                                                            offer: (id: string) => Offer;
                                                                                            • Used for reading, or updating a existing offer by id.

                                                                                              Parameter id

                                                                                              The id of the offer.

                                                                                            class CosmosDiagnostics

                                                                                            class CosmosDiagnostics {}
                                                                                            • * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create(). It has three members - 1. clientSideRequestStatistics member contains aggregate diagnostic information, including - - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls. i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call. - retries - endpoints contacted. - request, response payload stats. - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation.

                                                                                              2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by CosmosDbDiagnosticLevel. - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments. - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used in production environment. - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads. Is not meant to be used in production environment. 3. clientConfig - Captures information related to how client was configured during initialization.

                                                                                            property clientConfig

                                                                                            readonly clientConfig?: ClientConfigDiagnostic;

                                                                                              property clientSideRequestStatistics

                                                                                              readonly clientSideRequestStatistics: ClientSideRequestStatistics;

                                                                                                property diagnosticNode

                                                                                                readonly diagnosticNode: DiagnosticNode;

                                                                                                  class Database

                                                                                                  class Database {}
                                                                                                  • Operations for reading or deleting an existing database.

                                                                                                    See Also

                                                                                                    • Databases for creating new databases, and reading/querying all databases; use client.databases.

                                                                                                      Note: all these operations make calls against a fixed budget. You should design your system such that these calls scale sublinearly with your application. For instance, do not call database.read() before every single item.read() call, to ensure the database exists; do this once on application start up.

                                                                                                  constructor

                                                                                                  constructor(client: CosmosClient, id: string, clientContext: ClientContext);
                                                                                                  • Returns a new Database instance.

                                                                                                    Note: the intention is to get this object from CosmosClient via client.database(id), not to instantiate it yourself.

                                                                                                  property client

                                                                                                  readonly client: CosmosClient;

                                                                                                    property containers

                                                                                                    readonly containers: Containers;
                                                                                                    • Used for creating new containers, or querying/reading all containers.

                                                                                                      Use .database(id) to read, replace, or delete a specific, existing Database by id.

                                                                                                      Example 1

                                                                                                      Create a new container

                                                                                                      const {body: containerDefinition, container} = await client.database("<db id>").containers.create({id: "<container id>"});

                                                                                                    property id

                                                                                                    readonly id: string;

                                                                                                      property url

                                                                                                      readonly url: string;
                                                                                                      • Returns a reference URL to the resource. Used for linking in Permissions.

                                                                                                      property users

                                                                                                      readonly users: Users;
                                                                                                      • Used for creating new users, or querying/reading all users.

                                                                                                        Use .user(id) to read, replace, or delete a specific, existing User by id.

                                                                                                      method container

                                                                                                      container: (id: string) => Container;
                                                                                                      • Used to read, replace, or delete a specific, existing Database by id.

                                                                                                        Use .containers creating new containers, or querying/reading all containers.

                                                                                                        Example 1

                                                                                                        Delete a container

                                                                                                        await client.database("<db id>").container("<container id>").delete();

                                                                                                      method delete

                                                                                                      delete: (options?: RequestOptions) => Promise<DatabaseResponse>;
                                                                                                      • Delete the given Database.

                                                                                                      method read

                                                                                                      read: (options?: RequestOptions) => Promise<DatabaseResponse>;
                                                                                                      • Read the definition of the given Database.

                                                                                                      method readInternal

                                                                                                      readInternal: (
                                                                                                      diagnosticNode: DiagnosticNodeInternal,
                                                                                                      options?: RequestOptions
                                                                                                      ) => Promise<DatabaseResponse>;

                                                                                                      method readOffer

                                                                                                      readOffer: (options?: RequestOptions) => Promise<OfferResponse>;
                                                                                                      • Gets offer on database. If none exists, returns an OfferResponse with undefined.

                                                                                                      method user

                                                                                                      user: (id: string) => User;
                                                                                                      • Used to read, replace, or delete a specific, existing User by id.

                                                                                                        Use .users for creating new users, or querying/reading all users.

                                                                                                      class DatabaseAccount

                                                                                                      class DatabaseAccount {}
                                                                                                      • Represents a DatabaseAccount in the Azure Cosmos DB database service.

                                                                                                      constructor

                                                                                                      constructor(body: { [key: string]: any }, headers: CosmosHeaders);

                                                                                                        property consistencyPolicy

                                                                                                        readonly consistencyPolicy: ConsistencyLevel;
                                                                                                        • Gets the UserConsistencyPolicy settings.

                                                                                                        property ConsistencyPolicy

                                                                                                        readonly ConsistencyPolicy: ConsistencyLevel;
                                                                                                        • Gets the UserConsistencyPolicy settings.

                                                                                                          Deprecated

                                                                                                          use consistencyPolicy

                                                                                                        property currentMediaStorageUsageInMB

                                                                                                        readonly currentMediaStorageUsageInMB: number;
                                                                                                        • Current attachment content (media) usage in MBs (Retrieved from gateway )

                                                                                                          Value is returned from cached information updated periodically and is not guaranteed to be real time.

                                                                                                        property CurrentMediaStorageUsageInMB

                                                                                                        readonly CurrentMediaStorageUsageInMB: number;
                                                                                                        • Current attachment content (media) usage in MBs (Retrieved from gateway )

                                                                                                          Value is returned from cached information updated periodically and is not guaranteed to be real time.

                                                                                                          Deprecated

                                                                                                          use currentMediaStorageUsageInMB

                                                                                                        readonly databasesLink: string;
                                                                                                        • The self-link for Databases in the databaseAccount.

                                                                                                        readonly DatabasesLink: string;
                                                                                                        • The self-link for Databases in the databaseAccount.

                                                                                                          Deprecated

                                                                                                          Use databasesLink

                                                                                                        property enableMultipleWritableLocations

                                                                                                        readonly enableMultipleWritableLocations: boolean;

                                                                                                          property maxMediaStorageUsageInMB

                                                                                                          readonly maxMediaStorageUsageInMB: number;
                                                                                                          • Attachment content (media) storage quota in MBs ( Retrieved from gateway ).

                                                                                                          property MaxMediaStorageUsageInMB

                                                                                                          readonly MaxMediaStorageUsageInMB: number;
                                                                                                          • Attachment content (media) storage quota in MBs ( Retrieved from gateway ).

                                                                                                            Deprecated

                                                                                                            use maxMediaStorageUsageInMB

                                                                                                          readonly mediaLink: string;
                                                                                                          • The self-link for Media in the databaseAccount.

                                                                                                          readonly MediaLink: string;
                                                                                                          • The self-link for Media in the databaseAccount.

                                                                                                            Deprecated

                                                                                                            Use mediaLink

                                                                                                          property readableLocations

                                                                                                          readonly readableLocations: Location_2[];
                                                                                                          • The list of readable locations for a geo-replicated database account.

                                                                                                          property writableLocations

                                                                                                          readonly writableLocations: Location_2[];
                                                                                                          • The list of writable locations for a geo-replicated database account.

                                                                                                          class DatabaseResponse

                                                                                                          class DatabaseResponse extends ResourceResponse<DatabaseDefinition & Resource> {}
                                                                                                          • Response object for Database operations

                                                                                                          constructor

                                                                                                          constructor(
                                                                                                          resource: DatabaseDefinition & Resource,
                                                                                                          headers: CosmosHeaders,
                                                                                                          statusCode: number,
                                                                                                          database: Database,
                                                                                                          diagnostics: CosmosDiagnostics
                                                                                                          );

                                                                                                            property database

                                                                                                            readonly database: Database;

                                                                                                            class Databases

                                                                                                            class Databases {}
                                                                                                            • Operations for creating new databases, and reading/querying all databases

                                                                                                              See Also

                                                                                                              • Database for reading or deleting an existing database; use client.database(id).

                                                                                                                Note: all these operations make calls against a fixed budget. You should design your system such that these calls scale sublinearly with your application. For instance, do not call databases.readAll() before every single item.read() call, to ensure the database exists; do this once on application start up.

                                                                                                            constructor

                                                                                                            constructor(client: CosmosClient, clientContext: ClientContext);

                                                                                                            property client

                                                                                                            readonly client: CosmosClient;

                                                                                                              method create

                                                                                                              create: (
                                                                                                              body: DatabaseRequest,
                                                                                                              options?: RequestOptions
                                                                                                              ) => Promise<DatabaseResponse>;
                                                                                                              • Send a request for creating a database.

                                                                                                                A database manages users, permissions and a set of containers. Each Azure Cosmos DB Database Account is able to support multiple independent named databases, with the database being the logical container for data.

                                                                                                                Each Database consists of one or more containers, each of which in turn contain one or more documents. Since databases are an administrative resource, the Service Master Key will be required in order to access and successfully complete any action using the User APIs.

                                                                                                                Parameter body

                                                                                                                The DatabaseDefinition that represents the Database to be created.

                                                                                                                Parameter options

                                                                                                                Use to set options like response page size, continuation tokens, etc.

                                                                                                              method createIfNotExists

                                                                                                              createIfNotExists: (
                                                                                                              body: DatabaseRequest,
                                                                                                              options?: RequestOptions
                                                                                                              ) => Promise<DatabaseResponse>;
                                                                                                              • Check if a database exists, and if it doesn't, create it. This will make a read operation based on the id in the body, then if it is not found, a create operation.

                                                                                                                A database manages users, permissions and a set of containers. Each Azure Cosmos DB Database Account is able to support multiple independent named databases, with the database being the logical container for data.

                                                                                                                Each Database consists of one or more containers, each of which in turn contain one or more documents. Since databases are an an administrative resource, the Service Master Key will be required in order to access and successfully complete any action using the User APIs.

                                                                                                                Parameter body

                                                                                                                The DatabaseDefinition that represents the Database to be created.

                                                                                                                Parameter options

                                                                                                                Additional options for the request

                                                                                                              method createInternal

                                                                                                              createInternal: (
                                                                                                              diagnosticNode: DiagnosticNodeInternal,
                                                                                                              body: DatabaseRequest,
                                                                                                              options?: RequestOptions
                                                                                                              ) => Promise<DatabaseResponse>;

                                                                                                              method query

                                                                                                              query: {
                                                                                                              (query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
                                                                                                              <T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
                                                                                                              };
                                                                                                              • Queries all databases.

                                                                                                                Parameter query

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

                                                                                                                Parameter options

                                                                                                                Use to set options like response page size, continuation tokens, etc.

                                                                                                                Returns

                                                                                                                QueryIterator Allows you to return all databases in an array or iterate over them one at a time.

                                                                                                                Example 1

                                                                                                                Read all databases to array.

                                                                                                                const querySpec: SqlQuerySpec = {
                                                                                                                query: "SELECT * FROM root r WHERE r.id = @db",
                                                                                                                parameters: [
                                                                                                                {name: "@db", value: "Todo"}
                                                                                                                ]
                                                                                                                };
                                                                                                                const {body: databaseList} = await client.databases.query(querySpec).fetchAll();
                                                                                                              • Queries all databases.

                                                                                                                Parameter query

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

                                                                                                                Parameter options

                                                                                                                Use to set options like response page size, continuation tokens, etc.

                                                                                                                Returns

                                                                                                                QueryIterator Allows you to return all databases in an array or iterate over them one at a time.

                                                                                                                Example 1

                                                                                                                Read all databases to array.

                                                                                                                const querySpec: SqlQuerySpec = {
                                                                                                                query: "SELECT * FROM root r WHERE r.id = @db",
                                                                                                                parameters: [
                                                                                                                {name: "@db", value: "Todo"}
                                                                                                                ]
                                                                                                                };
                                                                                                                const {body: databaseList} = await client.databases.query(querySpec).fetchAll();

                                                                                                              method readAll

                                                                                                              readAll: (options?: FeedOptions) => QueryIterator<DatabaseDefinition & Resource>;
                                                                                                              • Reads all databases.

                                                                                                                Parameter options

                                                                                                                Use to set options like response page size, continuation tokens, etc.

                                                                                                                Returns

                                                                                                                QueryIterator Allows you to return all databases in an array or iterate over them one at a time.

                                                                                                                Example 1

                                                                                                                Read all databases to array.

                                                                                                                const {body: databaseList} = await client.databases.readAll().fetchAll();

                                                                                                              class DiagnosticNodeInternal

                                                                                                              class DiagnosticNodeInternal implements DiagnosticNode {}
                                                                                                              • This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect diagnostic information throughout the lifetime of Diagnostic session. The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart.

                                                                                                              property children

                                                                                                              children: DiagnosticNodeInternal[];

                                                                                                                property data

                                                                                                                data: Partial<DiagnosticDataValue>;

                                                                                                                  property diagnosticLevel

                                                                                                                  diagnosticLevel: CosmosDbDiagnosticLevel;

                                                                                                                    property durationInMs

                                                                                                                    durationInMs: number;

                                                                                                                      property id

                                                                                                                      id: string;

                                                                                                                        property nodeType

                                                                                                                        nodeType: DiagnosticNodeType;

                                                                                                                          property parent

                                                                                                                          parent: DiagnosticNodeInternal;

                                                                                                                            property startTimeUTCInMs

                                                                                                                            startTimeUTCInMs: number;

                                                                                                                              class ErrorResponse

                                                                                                                              class ErrorResponse extends Error {}

                                                                                                                                property activityId

                                                                                                                                activityId?: string;

                                                                                                                                  property body

                                                                                                                                  body?: ErrorBody;

                                                                                                                                    property code

                                                                                                                                    code?: string | number;

                                                                                                                                      property diagnostics

                                                                                                                                      diagnostics?: CosmosDiagnostics;

                                                                                                                                        property headers

                                                                                                                                        headers?: CosmosHeaders;

                                                                                                                                          property retryAfterInMilliseconds

                                                                                                                                          retryAfterInMilliseconds?: number;

                                                                                                                                            property retryAfterInMs

                                                                                                                                            retryAfterInMs?: number;

                                                                                                                                              property substatus

                                                                                                                                              substatus?: number;

                                                                                                                                                class FeedRange

                                                                                                                                                abstract class FeedRange {}
                                                                                                                                                • Specifies a feed range for the changefeed.

                                                                                                                                                property maxExclusive

                                                                                                                                                readonly maxExclusive: string;
                                                                                                                                                • Max value for the feed range.

                                                                                                                                                property minInclusive

                                                                                                                                                readonly minInclusive: string;
                                                                                                                                                • Min value for the feed range.

                                                                                                                                                class FeedResponse

                                                                                                                                                class FeedResponse<TResource> {}

                                                                                                                                                  constructor

                                                                                                                                                  constructor(
                                                                                                                                                  resources: TResource[],
                                                                                                                                                  headers: CosmosHeaders,
                                                                                                                                                  hasMoreResults: boolean,
                                                                                                                                                  diagnostics: CosmosDiagnostics
                                                                                                                                                  );

                                                                                                                                                    property activityId

                                                                                                                                                    readonly activityId: string;

                                                                                                                                                      property continuation

                                                                                                                                                      readonly continuation: string;

                                                                                                                                                        property continuationToken

                                                                                                                                                        readonly continuationToken: string;

                                                                                                                                                          property diagnostics

                                                                                                                                                          readonly diagnostics: CosmosDiagnostics;

                                                                                                                                                            property hasMoreResults

                                                                                                                                                            readonly hasMoreResults: boolean;

                                                                                                                                                              property indexMetrics

                                                                                                                                                              readonly indexMetrics: string;

                                                                                                                                                                property queryMetrics

                                                                                                                                                                readonly queryMetrics: string;

                                                                                                                                                                  property requestCharge

                                                                                                                                                                  readonly requestCharge: number;

                                                                                                                                                                    property resources

                                                                                                                                                                    readonly resources: TResource[];

                                                                                                                                                                      class GlobalEndpointManager

                                                                                                                                                                      class GlobalEndpointManager {}
                                                                                                                                                                      • This internal class implements the logic for endpoint management for geo-replicated database accounts.

                                                                                                                                                                      property enableEndpointDiscovery

                                                                                                                                                                      enableEndpointDiscovery: boolean;
                                                                                                                                                                      • Flag to enable/disable automatic redirecting of requests based on read/write operations.

                                                                                                                                                                      property preferredLocationsCount

                                                                                                                                                                      preferredLocationsCount: number;

                                                                                                                                                                        method canUseMultipleWriteLocations

                                                                                                                                                                        canUseMultipleWriteLocations: (
                                                                                                                                                                        resourceType?: ResourceType,
                                                                                                                                                                        operationType?: OperationType
                                                                                                                                                                        ) => boolean;

                                                                                                                                                                          method getReadEndpoint

                                                                                                                                                                          getReadEndpoint: (diagnosticNode: DiagnosticNodeInternal) => Promise<string>;
                                                                                                                                                                          • Gets the current read endpoint from the endpoint cache.

                                                                                                                                                                          method getReadEndpoints

                                                                                                                                                                          getReadEndpoints: () => Promise<ReadonlyArray<string>>;

                                                                                                                                                                            method getWriteEndpoint

                                                                                                                                                                            getWriteEndpoint: (diagnosticNode: DiagnosticNodeInternal) => Promise<string>;
                                                                                                                                                                            • Gets the current write endpoint from the endpoint cache.

                                                                                                                                                                            method getWriteEndpoints

                                                                                                                                                                            getWriteEndpoints: () => Promise<ReadonlyArray<string>>;

                                                                                                                                                                              method markCurrentLocationUnavailableForRead

                                                                                                                                                                              markCurrentLocationUnavailableForRead: (
                                                                                                                                                                              diagnosticNode: DiagnosticNodeInternal,
                                                                                                                                                                              endpoint: string
                                                                                                                                                                              ) => Promise<void>;

                                                                                                                                                                                method markCurrentLocationUnavailableForWrite

                                                                                                                                                                                markCurrentLocationUnavailableForWrite: (
                                                                                                                                                                                diagnosticNode: DiagnosticNodeInternal,
                                                                                                                                                                                endpoint: string
                                                                                                                                                                                ) => Promise<void>;

                                                                                                                                                                                  method refreshEndpointList

                                                                                                                                                                                  refreshEndpointList: (diagnosticNode: DiagnosticNodeInternal) => Promise<void>;
                                                                                                                                                                                  • Refreshes the endpoint list by clearning stale unavailability and then retrieving the writable and readable locations from the geo-replicated database account and then updating the locations cache. We skip the refreshing if enableEndpointDiscovery is set to False

                                                                                                                                                                                  method resolveServiceEndpoint

                                                                                                                                                                                  resolveServiceEndpoint: (
                                                                                                                                                                                  diagnosticNode: DiagnosticNodeInternal,
                                                                                                                                                                                  resourceType: ResourceType,
                                                                                                                                                                                  operationType: OperationType,
                                                                                                                                                                                  startServiceEndpointIndex?: number
                                                                                                                                                                                  ) => Promise<string>;

                                                                                                                                                                                    class Item

                                                                                                                                                                                    class Item {}
                                                                                                                                                                                    • Used to perform operations on a specific item.

                                                                                                                                                                                      See Also

                                                                                                                                                                                      • Items for operations on all items; see container.items.

                                                                                                                                                                                    constructor

                                                                                                                                                                                    constructor(
                                                                                                                                                                                    container: Container,
                                                                                                                                                                                    id: string,
                                                                                                                                                                                    clientContext: ClientContext,
                                                                                                                                                                                    partitionKey?: PartitionKey
                                                                                                                                                                                    );
                                                                                                                                                                                    • Parameter container

                                                                                                                                                                                      The parent Container.

                                                                                                                                                                                      Parameter id

                                                                                                                                                                                      The id of the given Item.

                                                                                                                                                                                      Parameter partitionKey

                                                                                                                                                                                      The primary key of the given Item (only for partitioned containers).

                                                                                                                                                                                    property container

                                                                                                                                                                                    readonly container: Container;

                                                                                                                                                                                      property id

                                                                                                                                                                                      readonly id: string;

                                                                                                                                                                                        property url

                                                                                                                                                                                        readonly url: string;
                                                                                                                                                                                        • Returns a reference URL to the resource. Used for linking in Permissions.

                                                                                                                                                                                        method delete

                                                                                                                                                                                        delete: <T extends ItemDefinition = any>(
                                                                                                                                                                                        options?: RequestOptions
                                                                                                                                                                                        ) => Promise<ItemResponse<T>>;
                                                                                                                                                                                        • Delete the 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.

                                                                                                                                                                                          Parameter options

                                                                                                                                                                                          Additional options for the request

                                                                                                                                                                                        method patch

                                                                                                                                                                                        patch: <T extends ItemDefinition = any>(
                                                                                                                                                                                        body: PatchRequestBody,
                                                                                                                                                                                        options?: RequestOptions
                                                                                                                                                                                        ) => Promise<ItemResponse<T>>;
                                                                                                                                                                                        • Perform a JSONPatch on the 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.

                                                                                                                                                                                          Parameter options

                                                                                                                                                                                          Additional options for the request

                                                                                                                                                                                        method read

                                                                                                                                                                                        read: <T extends ItemDefinition = any>(
                                                                                                                                                                                        options?: RequestOptions
                                                                                                                                                                                        ) => Promise<ItemResponse<T>>;
                                                                                                                                                                                        • Read the item's definition.

                                                                                                                                                                                          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. If the type, T, is a class, it won't pass typeof comparisons, because it won't have a match prototype. It's recommended to only use interfaces.

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

                                                                                                                                                                                          Parameter options

                                                                                                                                                                                          Additional options for the request

                                                                                                                                                                                          Example 1

                                                                                                                                                                                          Using custom type for response

                                                                                                                                                                                          interface TodoItem {
                                                                                                                                                                                          title: string;
                                                                                                                                                                                          done: bool;
                                                                                                                                                                                          id: string;
                                                                                                                                                                                          }
                                                                                                                                                                                          let item: TodoItem;
                                                                                                                                                                                          ({body: item} = await item.read<TodoItem>());

                                                                                                                                                                                        method replace

                                                                                                                                                                                        replace: {
                                                                                                                                                                                        (body: ItemDefinition, options?: RequestOptions): Promise<
                                                                                                                                                                                        ItemResponse<ItemDefinition>
                                                                                                                                                                                        >;
                                                                                                                                                                                        <T extends ItemDefinition>(body: T, options?: RequestOptions): Promise<
                                                                                                                                                                                        ItemResponse<T>
                                                                                                                                                                                        >;
                                                                                                                                                                                        };
                                                                                                                                                                                        • Replace the item's definition.

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

                                                                                                                                                                                          Parameter body

                                                                                                                                                                                          The definition to replace the existing Item's definition with.

                                                                                                                                                                                          Parameter options

                                                                                                                                                                                          Additional options for the request

                                                                                                                                                                                        • Replace the item's definition.

                                                                                                                                                                                          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.

                                                                                                                                                                                          Parameter body

                                                                                                                                                                                          The definition to replace the existing Item's definition with.

                                                                                                                                                                                          Parameter options

                                                                                                                                                                                          Additional options for the request

                                                                                                                                                                                        class ItemResponse

                                                                                                                                                                                        class ItemResponse<T extends ItemDefinition> extends ResourceResponse<
                                                                                                                                                                                        T & Resource
                                                                                                                                                                                        > {}

                                                                                                                                                                                          constructor

                                                                                                                                                                                          constructor(
                                                                                                                                                                                          resource: ItemDefinition & Resource,
                                                                                                                                                                                          headers: CosmosHeaders,
                                                                                                                                                                                          statusCode: number,
                                                                                                                                                                                          subsstatusCode: number,
                                                                                                                                                                                          item: Item,
                                                                                                                                                                                          diagnostics: CosmosDiagnostics
                                                                                                                                                                                          );

                                                                                                                                                                                            property item

                                                                                                                                                                                            readonly item: Item;
                                                                                                                                                                                            • Reference to the Item the response corresponds to.

                                                                                                                                                                                            class Items

                                                                                                                                                                                            class Items {}
                                                                                                                                                                                            • Operations for creating new items, and reading/querying all items

                                                                                                                                                                                              See Also

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

                                                                                                                                                                                            constructor

                                                                                                                                                                                            constructor(container: Container, clientContext: ClientContext);
                                                                                                                                                                                            • Create an instance of Items linked to the parent Container.

                                                                                                                                                                                              Parameter container

                                                                                                                                                                                              The parent container.

                                                                                                                                                                                            property container

                                                                                                                                                                                            readonly container: Container;

                                                                                                                                                                                              method batch

                                                                                                                                                                                              batch: (
                                                                                                                                                                                              operations: OperationInput[],
                                                                                                                                                                                              partitionKey?: PartitionKey,
                                                                                                                                                                                              options?: RequestOptions
                                                                                                                                                                                              ) => Promise<Response_2<OperationResponse[]>>;
                                                                                                                                                                                              • Execute transactional batch operations on items.

                                                                                                                                                                                                Batch takes an array of Operations which are typed based on what the operation does. Batch is transactional and will rollback all operations if one fails. The choices are: Create, Upsert, Read, Replace, and Delete

                                                                                                                                                                                                Usage example:

                                                                                                                                                                                                // partitionKey is required as a second argument to batch, but defaults to the default partition key
                                                                                                                                                                                                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.batch(operations)

                                                                                                                                                                                                Parameter operations

                                                                                                                                                                                                List of operations. Limit 100

                                                                                                                                                                                                Parameter options

                                                                                                                                                                                                Used for modifying the request

                                                                                                                                                                                              method bulk

                                                                                                                                                                                              bulk: (
                                                                                                                                                                                              operations: OperationInput[],
                                                                                                                                                                                              bulkOptions?: BulkOptions,
                                                                                                                                                                                              options?: RequestOptions
                                                                                                                                                                                              ) => Promise<BulkOperationResponse>;
                                                                                                                                                                                              • 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(operations)

                                                                                                                                                                                                Parameter operations

                                                                                                                                                                                                List of operations. Limit 100

                                                                                                                                                                                                Parameter bulkOptions

                                                                                                                                                                                                Optional options object to modify bulk behavior. Pass { continueOnError: true } to continue executing operations when one fails. (Defaults to false) ** NOTE: THIS WILL DEFAULT TO TRUE IN THE 4.0 RELEASE

                                                                                                                                                                                                Parameter options

                                                                                                                                                                                                Used for modifying the request.

                                                                                                                                                                                              method changeFeed

                                                                                                                                                                                              changeFeed: {
                                                                                                                                                                                              (
                                                                                                                                                                                              partitionKey: PartitionKey,
                                                                                                                                                                                              changeFeedOptions?: ChangeFeedOptions
                                                                                                                                                                                              ): ChangeFeedIterator<any>;
                                                                                                                                                                                              (changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
                                                                                                                                                                                              <T>(
                                                                                                                                                                                              partitionKey: PartitionKey,
                                                                                                                                                                                              changeFeedOptions?: ChangeFeedOptions
                                                                                                                                                                                              ): ChangeFeedIterator<T>;
                                                                                                                                                                                              <T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
                                                                                                                                                                                              };
                                                                                                                                                                                              • Create a ChangeFeedIterator to iterate over pages of changes

                                                                                                                                                                                                Example 1

                                                                                                                                                                                                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();
                                                                                                                                                                                              • Create a ChangeFeedIterator to iterate over pages of changes

                                                                                                                                                                                              method create

                                                                                                                                                                                              create: <T extends ItemDefinition = any>(
                                                                                                                                                                                              body: T,
                                                                                                                                                                                              options?: RequestOptions
                                                                                                                                                                                              ) => Promise<ItemResponse<T>>;
                                                                                                                                                                                              • 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.

                                                                                                                                                                                                Parameter body

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

                                                                                                                                                                                                Parameter options

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

                                                                                                                                                                                              method getChangeFeedIterator

                                                                                                                                                                                              getChangeFeedIterator: <T>(
                                                                                                                                                                                              changeFeedIteratorOptions?: ChangeFeedIteratorOptions
                                                                                                                                                                                              ) => ChangeFeedPullModelIterator<T>;
                                                                                                                                                                                              • Returns an iterator to iterate over pages of changes. The iterator returned can be used to fetch changes for a single partition key, feed range or an entire container.

                                                                                                                                                                                              method query

                                                                                                                                                                                              query: {
                                                                                                                                                                                              (query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
                                                                                                                                                                                              <T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
                                                                                                                                                                                              };
                                                                                                                                                                                              • Queries all items.

                                                                                                                                                                                                Parameter query

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

                                                                                                                                                                                                Parameter options

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

                                                                                                                                                                                                Example 1

                                                                                                                                                                                                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();
                                                                                                                                                                                              • Queries all items.

                                                                                                                                                                                                Parameter query

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

                                                                                                                                                                                                Parameter options

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

                                                                                                                                                                                                Example 1

                                                                                                                                                                                                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();

                                                                                                                                                                                              method readAll

                                                                                                                                                                                              readAll: {
                                                                                                                                                                                              (options?: FeedOptions): QueryIterator<ItemDefinition>;
                                                                                                                                                                                              <T extends ItemDefinition>(options?: FeedOptions): QueryIterator<T>;
                                                                                                                                                                                              };
                                                                                                                                                                                              • Read all items.

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

                                                                                                                                                                                                Parameter options

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

                                                                                                                                                                                                Example 1

                                                                                                                                                                                                Read all items to array.

                                                                                                                                                                                                const {body: containerList} = await items.readAll().fetchAll();
                                                                                                                                                                                              • 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.

                                                                                                                                                                                                Parameter options

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

                                                                                                                                                                                                Example 1

                                                                                                                                                                                                Read all items to array.

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

                                                                                                                                                                                              method readChangeFeed

                                                                                                                                                                                              readChangeFeed: {
                                                                                                                                                                                              (
                                                                                                                                                                                              partitionKey: PartitionKey,
                                                                                                                                                                                              changeFeedOptions?: ChangeFeedOptions
                                                                                                                                                                                              ): ChangeFeedIterator<any>;
                                                                                                                                                                                              (changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
                                                                                                                                                                                              <T>(
                                                                                                                                                                                              partitionKey: PartitionKey,
                                                                                                                                                                                              changeFeedOptions?: ChangeFeedOptions
                                                                                                                                                                                              ): ChangeFeedIterator<T>;
                                                                                                                                                                                              <T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
                                                                                                                                                                                              };
                                                                                                                                                                                              • Create a ChangeFeedIterator to iterate over pages of changes

                                                                                                                                                                                                Example 1

                                                                                                                                                                                                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();

                                                                                                                                                                                                Deprecated

                                                                                                                                                                                                Use changeFeed instead.

                                                                                                                                                                                              • Create a ChangeFeedIterator to iterate over pages of changes

                                                                                                                                                                                                Deprecated

                                                                                                                                                                                                Use changeFeed instead.

                                                                                                                                                                                              • Create a ChangeFeedIterator to iterate over pages of changes

                                                                                                                                                                                                Deprecated

                                                                                                                                                                                                Use changeFeed instead.

                                                                                                                                                                                              method upsert

                                                                                                                                                                                              upsert: {
                                                                                                                                                                                              (body: unknown, options?: RequestOptions): Promise<
                                                                                                                                                                                              ItemResponse<ItemDefinition>
                                                                                                                                                                                              >;
                                                                                                                                                                                              <T extends ItemDefinition>(body: T, options?: RequestOptions): Promise<
                                                                                                                                                                                              ItemResponse<T>
                                                                                                                                                                                              >;
                                                                                                                                                                                              };
                                                                                                                                                                                              • Upsert an item.

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

                                                                                                                                                                                                Parameter body

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

                                                                                                                                                                                                Parameter options

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

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

                                                                                                                                                                                                Parameter body

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

                                                                                                                                                                                                Parameter options

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

                                                                                                                                                                                              class Offer

                                                                                                                                                                                              class Offer {}
                                                                                                                                                                                              • Use to read or replace an existing Offer by id.

                                                                                                                                                                                                See Also

                                                                                                                                                                                                • Offers to query or read all offers.

                                                                                                                                                                                              constructor

                                                                                                                                                                                              constructor(client: CosmosClient, id: string, clientContext: ClientContext);
                                                                                                                                                                                              • Parameter client

                                                                                                                                                                                                The parent CosmosClient for the Database Account.

                                                                                                                                                                                                Parameter id

                                                                                                                                                                                                The id of the given Offer.

                                                                                                                                                                                              property client

                                                                                                                                                                                              readonly client: CosmosClient;

                                                                                                                                                                                                property id

                                                                                                                                                                                                readonly id: string;

                                                                                                                                                                                                  property url

                                                                                                                                                                                                  readonly url: string;
                                                                                                                                                                                                  • Returns a reference URL to the resource. Used for linking in Permissions.

                                                                                                                                                                                                  method read

                                                                                                                                                                                                  read: (options?: RequestOptions) => Promise<OfferResponse>;

                                                                                                                                                                                                  method replace

                                                                                                                                                                                                  replace: (
                                                                                                                                                                                                  body: OfferDefinition,
                                                                                                                                                                                                  options?: RequestOptions
                                                                                                                                                                                                  ) => Promise<OfferResponse>;

                                                                                                                                                                                                  class OfferResponse

                                                                                                                                                                                                  class OfferResponse extends ResourceResponse<OfferDefinition & Resource> {}

                                                                                                                                                                                                    constructor

                                                                                                                                                                                                    constructor(
                                                                                                                                                                                                    resource: OfferDefinition & Resource,
                                                                                                                                                                                                    headers: CosmosHeaders,
                                                                                                                                                                                                    statusCode: number,
                                                                                                                                                                                                    diagnostics: CosmosDiagnostics,
                                                                                                                                                                                                    offer?: Offer
                                                                                                                                                                                                    );

                                                                                                                                                                                                      property offer

                                                                                                                                                                                                      readonly offer: Offer;

                                                                                                                                                                                                      class Offers

                                                                                                                                                                                                      class Offers {}
                                                                                                                                                                                                      • Use to query or read all Offers.

                                                                                                                                                                                                        See Also

                                                                                                                                                                                                      constructor

                                                                                                                                                                                                      constructor(client: CosmosClient, clientContext: ClientContext);

                                                                                                                                                                                                      property client

                                                                                                                                                                                                      readonly client: CosmosClient;

                                                                                                                                                                                                        method query

                                                                                                                                                                                                        query: {
                                                                                                                                                                                                        (query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
                                                                                                                                                                                                        <T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
                                                                                                                                                                                                        };
                                                                                                                                                                                                        • Query all offers.

                                                                                                                                                                                                          Parameter query

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

                                                                                                                                                                                                        method readAll

                                                                                                                                                                                                        readAll: (options?: FeedOptions) => QueryIterator<OfferDefinition & Resource>;
                                                                                                                                                                                                        • Read all offers.

                                                                                                                                                                                                          Example 1

                                                                                                                                                                                                          Read all offers to array.

                                                                                                                                                                                                          const {body: offerList} = await client.offers.readAll().fetchAll();

                                                                                                                                                                                                        class PartitionKeyBuilder

                                                                                                                                                                                                        class PartitionKeyBuilder {}
                                                                                                                                                                                                        • Builder class for building PartitionKey.

                                                                                                                                                                                                        property values

                                                                                                                                                                                                        readonly values: PrimitivePartitionKeyValue[];

                                                                                                                                                                                                          method addNoneValue

                                                                                                                                                                                                          addNoneValue: () => PartitionKeyBuilder;

                                                                                                                                                                                                            method addNullValue

                                                                                                                                                                                                            addNullValue: () => PartitionKeyBuilder;

                                                                                                                                                                                                              method addValue

                                                                                                                                                                                                              addValue: (value: string | boolean | number) => PartitionKeyBuilder;

                                                                                                                                                                                                                method build

                                                                                                                                                                                                                build: () => PartitionKey;

                                                                                                                                                                                                                  class Permission

                                                                                                                                                                                                                  class Permission {}
                                                                                                                                                                                                                  • Use to read, replace, or delete a given Permission by id.

                                                                                                                                                                                                                    See Also

                                                                                                                                                                                                                    • Permissions to create, upsert, query, or read all Permissions.

                                                                                                                                                                                                                  constructor

                                                                                                                                                                                                                  constructor(user: User, id: string, clientContext: ClientContext);
                                                                                                                                                                                                                  • Parameter user

                                                                                                                                                                                                                    The parent User.

                                                                                                                                                                                                                    Parameter id

                                                                                                                                                                                                                    The id of the given Permission.

                                                                                                                                                                                                                  property id

                                                                                                                                                                                                                  readonly id: string;

                                                                                                                                                                                                                    property url

                                                                                                                                                                                                                    readonly url: string;
                                                                                                                                                                                                                    • Returns a reference URL to the resource. Used for linking in Permissions.

                                                                                                                                                                                                                    property user

                                                                                                                                                                                                                    readonly user: User;

                                                                                                                                                                                                                      method delete

                                                                                                                                                                                                                      delete: (options?: RequestOptions) => Promise<PermissionResponse>;

                                                                                                                                                                                                                      method read

                                                                                                                                                                                                                      read: (options?: RequestOptions) => Promise<PermissionResponse>;

                                                                                                                                                                                                                      method replace

                                                                                                                                                                                                                      replace: (
                                                                                                                                                                                                                      body: PermissionDefinition,
                                                                                                                                                                                                                      options?: RequestOptions
                                                                                                                                                                                                                      ) => Promise<PermissionResponse>;

                                                                                                                                                                                                                      class PermissionResponse

                                                                                                                                                                                                                      class PermissionResponse extends ResourceResponse<
                                                                                                                                                                                                                      PermissionDefinition & PermissionBody & Resource
                                                                                                                                                                                                                      > {}

                                                                                                                                                                                                                        constructor

                                                                                                                                                                                                                        constructor(
                                                                                                                                                                                                                        resource: PermissionDefinition & PermissionBody & Resource,
                                                                                                                                                                                                                        headers: CosmosHeaders,
                                                                                                                                                                                                                        statusCode: number,
                                                                                                                                                                                                                        permission: Permission,
                                                                                                                                                                                                                        diagnostics: CosmosDiagnostics
                                                                                                                                                                                                                        );

                                                                                                                                                                                                                          property permission

                                                                                                                                                                                                                          readonly permission: Permission;

                                                                                                                                                                                                                          class Permissions

                                                                                                                                                                                                                          class Permissions_2 {}
                                                                                                                                                                                                                          • Use to create, replace, query, and read all Permissions.

                                                                                                                                                                                                                            See Also

                                                                                                                                                                                                                            • Permission to read, replace, or delete a specific permission by id.

                                                                                                                                                                                                                          constructor

                                                                                                                                                                                                                          constructor(user: User, clientContext: ClientContext);
                                                                                                                                                                                                                          • Parameter user

                                                                                                                                                                                                                            The parent User.

                                                                                                                                                                                                                          property user

                                                                                                                                                                                                                          readonly user: User;

                                                                                                                                                                                                                            method create

                                                                                                                                                                                                                            create: (
                                                                                                                                                                                                                            body: PermissionDefinition,
                                                                                                                                                                                                                            options?: RequestOptions
                                                                                                                                                                                                                            ) => Promise<PermissionResponse>;
                                                                                                                                                                                                                            • Create a permission.

                                                                                                                                                                                                                              A permission represents a per-User Permission to access a specific resource e.g. Item or Container.

                                                                                                                                                                                                                              Parameter body

                                                                                                                                                                                                                              Represents the body of the permission.

                                                                                                                                                                                                                            method query

                                                                                                                                                                                                                            query: {
                                                                                                                                                                                                                            (query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
                                                                                                                                                                                                                            <T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
                                                                                                                                                                                                                            };
                                                                                                                                                                                                                            • Query all permissions.

                                                                                                                                                                                                                              Parameter query

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

                                                                                                                                                                                                                            method readAll

                                                                                                                                                                                                                            readAll: (
                                                                                                                                                                                                                            options?: FeedOptions
                                                                                                                                                                                                                            ) => QueryIterator<PermissionDefinition & Resource>;
                                                                                                                                                                                                                            • Read all permissions.

                                                                                                                                                                                                                              Example 1

                                                                                                                                                                                                                              Read all permissions to array.

                                                                                                                                                                                                                              const {body: permissionList} = await user.permissions.readAll().fetchAll();

                                                                                                                                                                                                                            method upsert

                                                                                                                                                                                                                            upsert: (
                                                                                                                                                                                                                            body: PermissionDefinition,
                                                                                                                                                                                                                            options?: RequestOptions
                                                                                                                                                                                                                            ) => Promise<PermissionResponse>;
                                                                                                                                                                                                                            • Upsert a permission.

                                                                                                                                                                                                                              A permission represents a per-User Permission to access a specific resource e.g. Item or Container.

                                                                                                                                                                                                                            class QueryIterator

                                                                                                                                                                                                                            class QueryIterator<T> {}
                                                                                                                                                                                                                            • Represents a QueryIterator Object, an implementation of feed or query response that enables traversal and iterating over the response in the Azure Cosmos DB database service.

                                                                                                                                                                                                                            constructor

                                                                                                                                                                                                                            constructor(
                                                                                                                                                                                                                            clientContext: ClientContext,
                                                                                                                                                                                                                            query: string | SqlQuerySpec,
                                                                                                                                                                                                                            options: FeedOptions,
                                                                                                                                                                                                                            fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[],
                                                                                                                                                                                                                            resourceLink?: string,
                                                                                                                                                                                                                            resourceType?: ResourceType
                                                                                                                                                                                                                            );

                                                                                                                                                                                                                            method fetchAll

                                                                                                                                                                                                                            fetchAll: () => Promise<FeedResponse<T>>;
                                                                                                                                                                                                                            • Fetch all pages for the query and return a single FeedResponse.

                                                                                                                                                                                                                            method fetchAllInternal

                                                                                                                                                                                                                            fetchAllInternal: (
                                                                                                                                                                                                                            diagnosticNode: DiagnosticNodeInternal
                                                                                                                                                                                                                            ) => Promise<FeedResponse<T>>;

                                                                                                                                                                                                                            method fetchNext

                                                                                                                                                                                                                            fetchNext: () => Promise<FeedResponse<T>>;
                                                                                                                                                                                                                            • Retrieve the next batch from the feed.

                                                                                                                                                                                                                              This may or may not fetch more pages from the backend depending on your settings and the type of query. Aggregate queries will generally fetch all backend pages before returning the first batch of responses.

                                                                                                                                                                                                                            method getAsyncIterator

                                                                                                                                                                                                                            getAsyncIterator: () => AsyncIterable<FeedResponse<T>>;
                                                                                                                                                                                                                            • Gets an async iterator that will yield results until completion.

                                                                                                                                                                                                                              NOTE: AsyncIterators are a very new feature and you might need to use polyfils/etc. in order to use them in your code.

                                                                                                                                                                                                                              If you're using TypeScript, you can use the following polyfill as long as you target ES6 or higher and are running on Node 6 or higher.

                                                                                                                                                                                                                              if (!Symbol || !Symbol.asyncIterator) {
                                                                                                                                                                                                                              (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator");
                                                                                                                                                                                                                              }

                                                                                                                                                                                                                              Example 1

                                                                                                                                                                                                                              Iterate over all databases

                                                                                                                                                                                                                              for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) {
                                                                                                                                                                                                                              console.log(`Got ${db} from AsyncIterator`);
                                                                                                                                                                                                                              }

                                                                                                                                                                                                                            method hasMoreResults

                                                                                                                                                                                                                            hasMoreResults: () => boolean;
                                                                                                                                                                                                                            • Determine if there are still remaining resources to process based on the value of the continuation token or the elements remaining on the current batch in the QueryIterator.

                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                              true if there is other elements to process in the QueryIterator.

                                                                                                                                                                                                                            method reset

                                                                                                                                                                                                                            reset: () => void;
                                                                                                                                                                                                                            • Reset the QueryIterator to the beginning and clear all the resources inside it

                                                                                                                                                                                                                            class QueryMetrics

                                                                                                                                                                                                                            class QueryMetrics {}

                                                                                                                                                                                                                              constructor

                                                                                                                                                                                                                              constructor(
                                                                                                                                                                                                                              retrievedDocumentCount: number,
                                                                                                                                                                                                                              retrievedDocumentSize: number,
                                                                                                                                                                                                                              outputDocumentCount: number,
                                                                                                                                                                                                                              outputDocumentSize: number,
                                                                                                                                                                                                                              indexHitDocumentCount: number,
                                                                                                                                                                                                                              totalQueryExecutionTime: TimeSpan,
                                                                                                                                                                                                                              queryPreparationTimes: QueryPreparationTimes,
                                                                                                                                                                                                                              indexLookupTime: TimeSpan,
                                                                                                                                                                                                                              documentLoadTime: TimeSpan,
                                                                                                                                                                                                                              vmExecutionTime: TimeSpan,
                                                                                                                                                                                                                              runtimeExecutionTimes: RuntimeExecutionTimes,
                                                                                                                                                                                                                              documentWriteTime: TimeSpan,
                                                                                                                                                                                                                              clientSideMetrics: ClientSideMetrics
                                                                                                                                                                                                                              );

                                                                                                                                                                                                                                property clientSideMetrics

                                                                                                                                                                                                                                readonly clientSideMetrics: ClientSideMetrics;

                                                                                                                                                                                                                                  property documentLoadTime

                                                                                                                                                                                                                                  readonly documentLoadTime: TimeSpan;

                                                                                                                                                                                                                                    property documentWriteTime

                                                                                                                                                                                                                                    readonly documentWriteTime: TimeSpan;

                                                                                                                                                                                                                                      property indexHitDocumentCount

                                                                                                                                                                                                                                      readonly indexHitDocumentCount: number;

                                                                                                                                                                                                                                        property indexHitRatio

                                                                                                                                                                                                                                        readonly indexHitRatio: number;
                                                                                                                                                                                                                                        • Gets the IndexHitRatio

                                                                                                                                                                                                                                        property indexLookupTime

                                                                                                                                                                                                                                        readonly indexLookupTime: TimeSpan;

                                                                                                                                                                                                                                          property outputDocumentCount

                                                                                                                                                                                                                                          readonly outputDocumentCount: number;

                                                                                                                                                                                                                                            property outputDocumentSize

                                                                                                                                                                                                                                            readonly outputDocumentSize: number;

                                                                                                                                                                                                                                              property queryPreparationTimes

                                                                                                                                                                                                                                              readonly queryPreparationTimes: QueryPreparationTimes;

                                                                                                                                                                                                                                                property retrievedDocumentCount

                                                                                                                                                                                                                                                readonly retrievedDocumentCount: number;

                                                                                                                                                                                                                                                  property retrievedDocumentSize

                                                                                                                                                                                                                                                  readonly retrievedDocumentSize: number;

                                                                                                                                                                                                                                                    property runtimeExecutionTimes

                                                                                                                                                                                                                                                    readonly runtimeExecutionTimes: RuntimeExecutionTimes;

                                                                                                                                                                                                                                                      property totalQueryExecutionTime

                                                                                                                                                                                                                                                      readonly totalQueryExecutionTime: TimeSpan;

                                                                                                                                                                                                                                                        property vmExecutionTime

                                                                                                                                                                                                                                                        readonly vmExecutionTime: TimeSpan;

                                                                                                                                                                                                                                                          property zero

                                                                                                                                                                                                                                                          static readonly zero: QueryMetrics;

                                                                                                                                                                                                                                                            method add

                                                                                                                                                                                                                                                            add: (queryMetricsArray: QueryMetrics[]) => QueryMetrics;
                                                                                                                                                                                                                                                            • returns a new QueryMetrics instance that is the addition of this and the arguments.

                                                                                                                                                                                                                                                            method createFromArray

                                                                                                                                                                                                                                                            static createFromArray: (queryMetricsArray: QueryMetrics[]) => QueryMetrics;
                                                                                                                                                                                                                                                            • Returns a new instance of the QueryMetrics class that is the aggregation of an array of query metrics.

                                                                                                                                                                                                                                                            method createFromDelimitedString

                                                                                                                                                                                                                                                            static createFromDelimitedString: (
                                                                                                                                                                                                                                                            delimitedString: string,
                                                                                                                                                                                                                                                            clientSideMetrics?: ClientSideMetrics
                                                                                                                                                                                                                                                            ) => QueryMetrics;
                                                                                                                                                                                                                                                            • Returns a new instance of the QueryMetrics class this is deserialized from a delimited string.

                                                                                                                                                                                                                                                            method toDelimitedString

                                                                                                                                                                                                                                                            toDelimitedString: () => string;
                                                                                                                                                                                                                                                            • Output the QueryMetrics as a delimited string.

                                                                                                                                                                                                                                                            class QueryPreparationTimes

                                                                                                                                                                                                                                                            class QueryPreparationTimes {}

                                                                                                                                                                                                                                                              constructor

                                                                                                                                                                                                                                                              constructor(
                                                                                                                                                                                                                                                              queryCompilationTime: TimeSpan,
                                                                                                                                                                                                                                                              logicalPlanBuildTime: TimeSpan,
                                                                                                                                                                                                                                                              physicalPlanBuildTime: TimeSpan,
                                                                                                                                                                                                                                                              queryOptimizationTime: TimeSpan
                                                                                                                                                                                                                                                              );

                                                                                                                                                                                                                                                                property logicalPlanBuildTime

                                                                                                                                                                                                                                                                readonly logicalPlanBuildTime: TimeSpan;

                                                                                                                                                                                                                                                                  property physicalPlanBuildTime

                                                                                                                                                                                                                                                                  readonly physicalPlanBuildTime: TimeSpan;

                                                                                                                                                                                                                                                                    property queryCompilationTime

                                                                                                                                                                                                                                                                    readonly queryCompilationTime: TimeSpan;

                                                                                                                                                                                                                                                                      property queryOptimizationTime

                                                                                                                                                                                                                                                                      readonly queryOptimizationTime: TimeSpan;

                                                                                                                                                                                                                                                                        property zero

                                                                                                                                                                                                                                                                        static readonly zero: QueryPreparationTimes;

                                                                                                                                                                                                                                                                          method add

                                                                                                                                                                                                                                                                          add: (
                                                                                                                                                                                                                                                                          ...queryPreparationTimesArray: QueryPreparationTimes[]
                                                                                                                                                                                                                                                                          ) => QueryPreparationTimes;
                                                                                                                                                                                                                                                                          • returns a new QueryPreparationTimes instance that is the addition of this and the arguments.

                                                                                                                                                                                                                                                                          method createFromArray

                                                                                                                                                                                                                                                                          static createFromArray: (
                                                                                                                                                                                                                                                                          queryPreparationTimesArray: QueryPreparationTimes[]
                                                                                                                                                                                                                                                                          ) => QueryPreparationTimes;
                                                                                                                                                                                                                                                                          • Returns a new instance of the QueryPreparationTimes class that is the aggregation of an array of QueryPreparationTimes.

                                                                                                                                                                                                                                                                          method createFromDelimitedString

                                                                                                                                                                                                                                                                          static createFromDelimitedString: (
                                                                                                                                                                                                                                                                          delimitedString: string
                                                                                                                                                                                                                                                                          ) => QueryPreparationTimes;
                                                                                                                                                                                                                                                                          • Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string.

                                                                                                                                                                                                                                                                          method toDelimitedString

                                                                                                                                                                                                                                                                          toDelimitedString: () => string;
                                                                                                                                                                                                                                                                          • Output the QueryPreparationTimes as a delimited string.

                                                                                                                                                                                                                                                                          class ResourceResponse

                                                                                                                                                                                                                                                                          class ResourceResponse<TResource> {}

                                                                                                                                                                                                                                                                            constructor

                                                                                                                                                                                                                                                                            constructor(
                                                                                                                                                                                                                                                                            resource: {},
                                                                                                                                                                                                                                                                            headers: CosmosHeaders_2,
                                                                                                                                                                                                                                                                            statusCode: number,
                                                                                                                                                                                                                                                                            diagnostics: CosmosDiagnostics,
                                                                                                                                                                                                                                                                            substatus?: number
                                                                                                                                                                                                                                                                            );

                                                                                                                                                                                                                                                                              property activityId

                                                                                                                                                                                                                                                                              readonly activityId: string;

                                                                                                                                                                                                                                                                                property diagnostics

                                                                                                                                                                                                                                                                                readonly diagnostics: CosmosDiagnostics;

                                                                                                                                                                                                                                                                                  property etag

                                                                                                                                                                                                                                                                                  readonly etag: string;

                                                                                                                                                                                                                                                                                    property headers

                                                                                                                                                                                                                                                                                    readonly headers: CosmosHeaders_2;

                                                                                                                                                                                                                                                                                      property requestCharge

                                                                                                                                                                                                                                                                                      readonly requestCharge: number;

                                                                                                                                                                                                                                                                                        property resource

                                                                                                                                                                                                                                                                                        readonly resource: {};

                                                                                                                                                                                                                                                                                          property statusCode

                                                                                                                                                                                                                                                                                          readonly statusCode: number;

                                                                                                                                                                                                                                                                                            property substatus

                                                                                                                                                                                                                                                                                            readonly substatus?: number;

                                                                                                                                                                                                                                                                                              class RuntimeExecutionTimes

                                                                                                                                                                                                                                                                                              class RuntimeExecutionTimes {}

                                                                                                                                                                                                                                                                                                constructor

                                                                                                                                                                                                                                                                                                constructor(
                                                                                                                                                                                                                                                                                                queryEngineExecutionTime: TimeSpan,
                                                                                                                                                                                                                                                                                                systemFunctionExecutionTime: TimeSpan,
                                                                                                                                                                                                                                                                                                userDefinedFunctionExecutionTime: TimeSpan
                                                                                                                                                                                                                                                                                                );

                                                                                                                                                                                                                                                                                                  property queryEngineExecutionTime

                                                                                                                                                                                                                                                                                                  readonly queryEngineExecutionTime: TimeSpan;

                                                                                                                                                                                                                                                                                                    property systemFunctionExecutionTime

                                                                                                                                                                                                                                                                                                    readonly systemFunctionExecutionTime: TimeSpan;

                                                                                                                                                                                                                                                                                                      property userDefinedFunctionExecutionTime

                                                                                                                                                                                                                                                                                                      readonly userDefinedFunctionExecutionTime: TimeSpan;

                                                                                                                                                                                                                                                                                                        property zero

                                                                                                                                                                                                                                                                                                        static readonly zero: RuntimeExecutionTimes;

                                                                                                                                                                                                                                                                                                          method add

                                                                                                                                                                                                                                                                                                          add: (
                                                                                                                                                                                                                                                                                                          ...runtimeExecutionTimesArray: RuntimeExecutionTimes[]
                                                                                                                                                                                                                                                                                                          ) => RuntimeExecutionTimes;
                                                                                                                                                                                                                                                                                                          • returns a new RuntimeExecutionTimes instance that is the addition of this and the arguments.

                                                                                                                                                                                                                                                                                                          method createFromArray

                                                                                                                                                                                                                                                                                                          static createFromArray: (
                                                                                                                                                                                                                                                                                                          runtimeExecutionTimesArray: RuntimeExecutionTimes[]
                                                                                                                                                                                                                                                                                                          ) => RuntimeExecutionTimes;
                                                                                                                                                                                                                                                                                                          • Returns a new instance of the RuntimeExecutionTimes class that is the aggregation of an array of RuntimeExecutionTimes.

                                                                                                                                                                                                                                                                                                          method createFromDelimitedString

                                                                                                                                                                                                                                                                                                          static createFromDelimitedString: (
                                                                                                                                                                                                                                                                                                          delimitedString: string
                                                                                                                                                                                                                                                                                                          ) => RuntimeExecutionTimes;
                                                                                                                                                                                                                                                                                                          • Returns a new instance of the RuntimeExecutionTimes class this is deserialized from a delimited string.

                                                                                                                                                                                                                                                                                                          method toDelimitedString

                                                                                                                                                                                                                                                                                                          toDelimitedString: () => string;
                                                                                                                                                                                                                                                                                                          • Output the RuntimeExecutionTimes as a delimited string.

                                                                                                                                                                                                                                                                                                          class SasTokenProperties

                                                                                                                                                                                                                                                                                                          class SasTokenProperties {}

                                                                                                                                                                                                                                                                                                            property containerName

                                                                                                                                                                                                                                                                                                            containerName: string;

                                                                                                                                                                                                                                                                                                              property controlPlaneReaderScope

                                                                                                                                                                                                                                                                                                              controlPlaneReaderScope: number;

                                                                                                                                                                                                                                                                                                                property controlPlaneWriterScope

                                                                                                                                                                                                                                                                                                                controlPlaneWriterScope: number;

                                                                                                                                                                                                                                                                                                                  property cosmosContainerChildResourceKind

                                                                                                                                                                                                                                                                                                                  cosmosContainerChildResourceKind: CosmosContainerChildResourceKind;

                                                                                                                                                                                                                                                                                                                    property cosmosKeyType

                                                                                                                                                                                                                                                                                                                    cosmosKeyType: CosmosKeyType;

                                                                                                                                                                                                                                                                                                                      property databaseName

                                                                                                                                                                                                                                                                                                                      databaseName: string;

                                                                                                                                                                                                                                                                                                                        property dataPlaneReaderScope

                                                                                                                                                                                                                                                                                                                        dataPlaneReaderScope: number;

                                                                                                                                                                                                                                                                                                                          property dataPlaneWriterScope

                                                                                                                                                                                                                                                                                                                          dataPlaneWriterScope: number;

                                                                                                                                                                                                                                                                                                                            property expiryTime

                                                                                                                                                                                                                                                                                                                            expiryTime: Date;

                                                                                                                                                                                                                                                                                                                              property keyType

                                                                                                                                                                                                                                                                                                                              keyType: number | CosmosKeyType;

                                                                                                                                                                                                                                                                                                                                property partitionKeyValueRanges

                                                                                                                                                                                                                                                                                                                                partitionKeyValueRanges: string[];

                                                                                                                                                                                                                                                                                                                                  property resourceKind

                                                                                                                                                                                                                                                                                                                                  resourceKind: CosmosContainerChildResourceKind;

                                                                                                                                                                                                                                                                                                                                    property resourceName

                                                                                                                                                                                                                                                                                                                                    resourceName: string;

                                                                                                                                                                                                                                                                                                                                      property resourcePath

                                                                                                                                                                                                                                                                                                                                      resourcePath: string;

                                                                                                                                                                                                                                                                                                                                        property startTime

                                                                                                                                                                                                                                                                                                                                        startTime: Date;

                                                                                                                                                                                                                                                                                                                                          property user

                                                                                                                                                                                                                                                                                                                                          user: string;

                                                                                                                                                                                                                                                                                                                                            property userTag

                                                                                                                                                                                                                                                                                                                                            userTag: string;

                                                                                                                                                                                                                                                                                                                                              class Scripts

                                                                                                                                                                                                                                                                                                                                              class Scripts {}

                                                                                                                                                                                                                                                                                                                                                constructor

                                                                                                                                                                                                                                                                                                                                                constructor(container: Container, clientContext: ClientContext);

                                                                                                                                                                                                                                                                                                                                                property container

                                                                                                                                                                                                                                                                                                                                                readonly container: Container;

                                                                                                                                                                                                                                                                                                                                                  property storedProcedures

                                                                                                                                                                                                                                                                                                                                                  readonly storedProcedures: StoredProcedures;
                                                                                                                                                                                                                                                                                                                                                  • Operations for creating new stored procedures, and reading/querying all stored procedures.

                                                                                                                                                                                                                                                                                                                                                    For reading, replacing, or deleting an existing stored procedure, use .storedProcedure(id).

                                                                                                                                                                                                                                                                                                                                                  property triggers

                                                                                                                                                                                                                                                                                                                                                  readonly triggers: Triggers;
                                                                                                                                                                                                                                                                                                                                                  • Operations for creating new triggers, and reading/querying all triggers.

                                                                                                                                                                                                                                                                                                                                                    For reading, replacing, or deleting an existing trigger, use .trigger(id).

                                                                                                                                                                                                                                                                                                                                                  property userDefinedFunctions

                                                                                                                                                                                                                                                                                                                                                  readonly userDefinedFunctions: UserDefinedFunctions;
                                                                                                                                                                                                                                                                                                                                                  • Operations for creating new user defined functions, and reading/querying all user defined functions.

                                                                                                                                                                                                                                                                                                                                                    For reading, replacing, or deleting an existing user defined function, use .userDefinedFunction(id).

                                                                                                                                                                                                                                                                                                                                                  method storedProcedure

                                                                                                                                                                                                                                                                                                                                                  storedProcedure: (id: string) => StoredProcedure;
                                                                                                                                                                                                                                                                                                                                                  • Used to read, replace, or delete a specific, existing StoredProcedure by id.

                                                                                                                                                                                                                                                                                                                                                    Use .storedProcedures for creating new stored procedures, or querying/reading all stored procedures.

                                                                                                                                                                                                                                                                                                                                                    Parameter id

                                                                                                                                                                                                                                                                                                                                                    The id of the StoredProcedure.

                                                                                                                                                                                                                                                                                                                                                  method trigger

                                                                                                                                                                                                                                                                                                                                                  trigger: (id: string) => Trigger;
                                                                                                                                                                                                                                                                                                                                                  • Used to read, replace, or delete a specific, existing Trigger by id.

                                                                                                                                                                                                                                                                                                                                                    Use .triggers for creating new triggers, or querying/reading all triggers.

                                                                                                                                                                                                                                                                                                                                                    Parameter id

                                                                                                                                                                                                                                                                                                                                                    The id of the Trigger.

                                                                                                                                                                                                                                                                                                                                                  method userDefinedFunction

                                                                                                                                                                                                                                                                                                                                                  userDefinedFunction: (id: string) => UserDefinedFunction;
                                                                                                                                                                                                                                                                                                                                                  • Used to read, replace, or delete a specific, existing UserDefinedFunction by id.

                                                                                                                                                                                                                                                                                                                                                    Use .userDefinedFunctions for creating new user defined functions, or querying/reading all user defined functions.

                                                                                                                                                                                                                                                                                                                                                    Parameter id

                                                                                                                                                                                                                                                                                                                                                    The id of the UserDefinedFunction.

                                                                                                                                                                                                                                                                                                                                                  class StoredProcedure

                                                                                                                                                                                                                                                                                                                                                  class StoredProcedure {}
                                                                                                                                                                                                                                                                                                                                                  • Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id.

                                                                                                                                                                                                                                                                                                                                                    For operations to create, read all, or query Stored Procedures,

                                                                                                                                                                                                                                                                                                                                                  constructor

                                                                                                                                                                                                                                                                                                                                                  constructor(container: Container, id: string, clientContext: ClientContext);

                                                                                                                                                                                                                                                                                                                                                  property container

                                                                                                                                                                                                                                                                                                                                                  readonly container: Container;

                                                                                                                                                                                                                                                                                                                                                    property id

                                                                                                                                                                                                                                                                                                                                                    readonly id: string;

                                                                                                                                                                                                                                                                                                                                                      property url

                                                                                                                                                                                                                                                                                                                                                      readonly url: string;
                                                                                                                                                                                                                                                                                                                                                      • Returns a reference URL to the resource. Used for linking in Permissions.

                                                                                                                                                                                                                                                                                                                                                      method delete

                                                                                                                                                                                                                                                                                                                                                      delete: (options?: RequestOptions) => Promise<StoredProcedureResponse>;

                                                                                                                                                                                                                                                                                                                                                      method execute

                                                                                                                                                                                                                                                                                                                                                      execute: <T = any>(
                                                                                                                                                                                                                                                                                                                                                      partitionKey: PartitionKey,
                                                                                                                                                                                                                                                                                                                                                      params?: any[],
                                                                                                                                                                                                                                                                                                                                                      options?: RequestOptions
                                                                                                                                                                                                                                                                                                                                                      ) => Promise<ResourceResponse<T>>;
                                                                                                                                                                                                                                                                                                                                                      • Execute the given StoredProcedure.

                                                                                                                                                                                                                                                                                                                                                        The specified type, T, is not enforced by the client. Be sure to validate the response from the stored procedure matches the type, T, you provide.

                                                                                                                                                                                                                                                                                                                                                        Parameter partitionKey

                                                                                                                                                                                                                                                                                                                                                        The partition key to use when executing the stored procedure

                                                                                                                                                                                                                                                                                                                                                        Parameter params

                                                                                                                                                                                                                                                                                                                                                        Array of parameters to pass as arguments to the given StoredProcedure.

                                                                                                                                                                                                                                                                                                                                                        Parameter options

                                                                                                                                                                                                                                                                                                                                                        Additional options, such as the partition key to invoke the StoredProcedure on.

                                                                                                                                                                                                                                                                                                                                                      method read

                                                                                                                                                                                                                                                                                                                                                      read: (options?: RequestOptions) => Promise<StoredProcedureResponse>;

                                                                                                                                                                                                                                                                                                                                                      method replace

                                                                                                                                                                                                                                                                                                                                                      replace: (
                                                                                                                                                                                                                                                                                                                                                      body: StoredProcedureDefinition,
                                                                                                                                                                                                                                                                                                                                                      options?: RequestOptions
                                                                                                                                                                                                                                                                                                                                                      ) => Promise<StoredProcedureResponse>;

                                                                                                                                                                                                                                                                                                                                                      class StoredProcedureResponse

                                                                                                                                                                                                                                                                                                                                                      class StoredProcedureResponse extends ResourceResponse<
                                                                                                                                                                                                                                                                                                                                                      StoredProcedureDefinition & Resource
                                                                                                                                                                                                                                                                                                                                                      > {}

                                                                                                                                                                                                                                                                                                                                                        constructor

                                                                                                                                                                                                                                                                                                                                                        constructor(
                                                                                                                                                                                                                                                                                                                                                        resource: StoredProcedureDefinition & Resource,
                                                                                                                                                                                                                                                                                                                                                        headers: CosmosHeaders,
                                                                                                                                                                                                                                                                                                                                                        statusCode: number,
                                                                                                                                                                                                                                                                                                                                                        storedProcedure: StoredProcedure,
                                                                                                                                                                                                                                                                                                                                                        diagnostics: CosmosDiagnostics
                                                                                                                                                                                                                                                                                                                                                        );

                                                                                                                                                                                                                                                                                                                                                          property sproc

                                                                                                                                                                                                                                                                                                                                                          readonly sproc: StoredProcedure;

                                                                                                                                                                                                                                                                                                                                                          property storedProcedure

                                                                                                                                                                                                                                                                                                                                                          readonly storedProcedure: StoredProcedure;

                                                                                                                                                                                                                                                                                                                                                          class StoredProcedures

                                                                                                                                                                                                                                                                                                                                                          class StoredProcedures {}
                                                                                                                                                                                                                                                                                                                                                          • Operations for creating, upserting, or reading/querying all Stored Procedures.

                                                                                                                                                                                                                                                                                                                                                            For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see container.storedProcedure().

                                                                                                                                                                                                                                                                                                                                                          constructor

                                                                                                                                                                                                                                                                                                                                                          constructor(container: Container, clientContext: ClientContext);

                                                                                                                                                                                                                                                                                                                                                          property container

                                                                                                                                                                                                                                                                                                                                                          readonly container: Container;

                                                                                                                                                                                                                                                                                                                                                            method create

                                                                                                                                                                                                                                                                                                                                                            create: (
                                                                                                                                                                                                                                                                                                                                                            body: StoredProcedureDefinition,
                                                                                                                                                                                                                                                                                                                                                            options?: RequestOptions
                                                                                                                                                                                                                                                                                                                                                            ) => Promise<StoredProcedureResponse>;
                                                                                                                                                                                                                                                                                                                                                            • Create a StoredProcedure.

                                                                                                                                                                                                                                                                                                                                                              Azure Cosmos DB allows stored procedures to be executed in the storage tier, directly against an item container. The script gets executed under ACID transactions on the primary storage partition of the specified container. For additional details, refer to the server-side JavaScript API documentation.

                                                                                                                                                                                                                                                                                                                                                            method query

                                                                                                                                                                                                                                                                                                                                                            query: {
                                                                                                                                                                                                                                                                                                                                                            (query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
                                                                                                                                                                                                                                                                                                                                                            <T>(query: