@azure/cosmos package

Classes

ChangeFeedIterator

Provides iterator for change feed. Use Items.changeFeed() to get an instance of the iterator.

ChangeFeedResponse

A single response page from the Azure Cosmos DB Change Feed

ClientSideMetrics
Conflict

Use to read or delete a given Conflict by id.

See Conflicts to query or read all conflicts.

ConflictResponse
Conflicts

Use to query or read all conflicts.

See Conflict to read or delete a given Conflict by id.

Container

Operations for reading, replacing, or deleting a specific, existing container by id.

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

ContainerResponse

Response object for Container operations

Containers

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

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

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

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

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
});
Database

Operations for reading or deleting an existing database.

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

DatabaseAccount

Represents a DatabaseAccount in the Azure Cosmos DB database service.

DatabaseResponse

Response object for Database operations

Databases

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

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

FeedResponse
Item

Used to perform operations on a specific item.

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

ItemResponse
Items

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

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

Offer

Use to read or replace an existing Offer by id.

See Offers to query or read all offers.

OfferResponse
Offers

Use to query or read all Offers.

See Offer to read or replace an existing Offer by id.

Permission

Use to read, replace, or delete a given Permission by id.

See <xref:Permissions> to create, upsert, query, or read all Permissions.

PermissionResponse
Permissions_2

Use to create, replace, query, and read all Permissions.

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

QueryIterator

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.

QueryMetrics
QueryPreparationTimes
ResourceResponse
RuntimeExecutionTimes
SasTokenProperties
Scripts
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,

StoredProcedureResponse
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().

Trigger

Operations to read, replace, or delete a Trigger. Use container.triggers to create, upsert, query, or read all.

TriggerResponse
Triggers

Operations to create, upsert, query, and read all triggers. Use container.triggers to read, replace, or delete a Trigger.

User

Used to read, replace, and delete Users. Additionally, you can access the permissions for a given user via user.permission and user.permissions.

See Users to create, upsert, query, or read all.

UserDefinedFunction

Used to read, replace, or delete a specified User Definied Function by id.

See UserDefinedFunction to create, upsert, query, read all User Defined Functions.

UserDefinedFunctionResponse
UserDefinedFunctions

Used to create, upsert, query, or read all User Defined Functions.

See UserDefinedFunction to read, replace, or delete a given User Defined Function by id.

UserResponse
Users

Used to create, upsert, query, and read all users.

See User to read, replace, or delete a specific User by id.

Interfaces

@azure/cosmos.Index
Agent
BulkOptions

Options object used to modify bulk execution. continueOnError (Default value: false) - Continues bulk execution when an operation fails ** NOTE THIS WILL DEFAULT TO TRUE IN the 4.0 RELEASE

ChangeFeedOptions

Specifies options for the change feed Some of these options control where and when to start reading from the change feed. The order of precedence is:

  • continuation
  • startTime
  • startFromBeginning

If none of those options are set, it will start reading changes from the first ChangeFeedIterator.fetchNext() call.

ConflictDefinition
ConflictResolutionPolicy

Represents the conflict resolution policy configuration for specifying how to resolve conflicts in case writes from different regions result in conflicts on documents in the collection in the Azure Cosmos DB service.

ConnectionPolicy

Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service.

ContainerDefinition
ContainerRequest
CosmosClientOptions
CosmosHeaders
CosmosHeaders_2
CreateOperationInput
DatabaseDefinition
DatabaseRequest
DeleteOperationInput
ErrorBody
ErrorResponse
FeedOptions

The feed options and query methods.

GroupByAliasToAggregateType
IndexedPath
IndexingPolicy
ItemDefinition

Items in Cosmos DB are simply JSON objects. Most of the Item operations allow for your to provide your own type that extends the very simple ItemDefinition. You cannot use any reserved keys. You can see the reserved key list in <xref:ItemBody>

JSONArray
JSONObject
Location_2

Used to specify the locations that are available, read is index 1 and write is index 0.

OfferDefinition
OperationBase
OperationResponse
PartitionKeyDefinition
PartitionKeyRangePropertiesNames
PatchOperationInput
PermissionBody
PermissionDefinition
ReadOperationInput
ReplaceOperationInput
RequestOptions

Options that can be specified for a requested issued to the Azure Cosmos DB servers.=

Resource
RetryOptions

Represents the Retry policy assocated with throttled requests in the Azure Cosmos DB database service.

SharedOptions

Options that can be specified for a requested issued to the Azure Cosmos DB servers.=

SpatialIndex
SqlParameter

Represents a parameter in a Parameterized SQL query, specified in SqlQuerySpec

SqlQuerySpec

Represents a SQL query in the Azure Cosmos DB service. Queries with inputs should be parameterized to protect against SQL injection.

Example

Parameterized SQL Query

const query: SqlQuerySpec = {
  query: "SELECT * FROM Families f where f.lastName = @lastName",
  parameters: [
    {name: "@lastName", value: "Wakefield"}
  ]
};
StoredProcedureDefinition
TriggerDefinition
UniqueKey

Interface for a single unique key passed as part of UniqueKeyPolicy

UniqueKeyPolicy

Interface for setting unique keys on container creation

UpsertOperationInput
UserDefinedFunctionDefinition
UserDefinition

Type Aliases

AggregateType
BulkPatchOperation
CreateOperation
DeleteOperation
ExistingKeyOperation
GroupByExpressions
JSONValue
Operation
OperationInput
OperationWithItem
PartitionKey
PatchOperation
PatchRequestBody
ReadOperation
RemoveOperation
ReplaceOperation
TokenProvider
UpsertOperation
VerboseOmit

Enums

ConflictResolutionMode
ConnectionMode

Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode.

ConsistencyLevel

Represents the consistency levels supported for Azure Cosmos DB client operations.
The requested ConsistencyLevel must match or be weaker than that provisioned for the database account. Consistency levels. Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual.

See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels.

DataType

Defines a target data type of an index path specification in the Azure Cosmos DB service.

GeospatialType
IndexKind

Specifies the supported Index types.

IndexingMode

Specifies the supported indexing modes.

PermissionMode

Enum for permission mode values.

SpatialType
TriggerOperation

Enum for trigger operation values. specifies the operations on which a trigger should be executed.

TriggerType

Enum for trigger type values. Specifies the type of the trigger.

UserDefinedFunctionType

Enum for udf type values. Specifies the types of user defined functions.

Functions

createAuthorizationSasToken(string, SasTokenProperties)

Experimental internal only Generates the payload representing the permission configuration for the sas token.

Function Details

createAuthorizationSasToken(string, SasTokenProperties)

Experimental internal only Generates the payload representing the permission configuration for the sas token.

function createAuthorizationSasToken(masterKey: string, sasTokenProperties: SasTokenProperties): Promise<string>

Parameters

masterKey

string

sasTokenProperties
SasTokenProperties

Returns

Promise<string>