@azure/cosmos package

Classes

ChangeFeedIterator

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

ChangeFeedResponse

A single response page from the Azure Cosmos DB Change Feed

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.

Conflict

Use to read or delete a given <xref:Conflict> by id.

Conflicts

Use to query or read all conflicts.

Container

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

Containers

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

Database

Operations for reading or deleting an existing database.

Databases

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

Item

Used to perform operations on a specific item.

Items

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

Offer

Use to read or replace an existing <xref:Offer> by id.

Offers

Use to query or read all Offers.

Permission

Use to read, replace, or delete a given <xref:Permission> by id.

Permissions

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

StoredProcedure

Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id. For operations to create, upsert, read all, or query Stored Procedures,

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 <xref:Trigger>. Use container.triggers to create, upsert, query, or read all.

Triggers

Operations to create, upsert, query, and read all triggers. Use container.triggers to read, replace, or delete a <xref: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.

Users

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

UserDefinedFunction

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

UserDefinedFunctions

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

ConnectionPolicy

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

DatabaseAccount

Represents a DatabaseAccount in the Azure Cosmos DB database service.

QueryIterator

Represents a QueryIterator Object, an implmenetation of feed or query response that enables traversal and iterating over the response in the Azure Cosmos DB database service.

ClientSideMetrics
QueryMetrics
QueryMetricsUtils
QueryPreparationTimes
RuntimeExecutionTimes
LocationRouting
RetryOptions

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

Interfaces

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.executeNext() call.

Agent
CosmosClientOptions
AuthOptions
ITokenProvider
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.

ConflictResponse
ContainerDefinition
ContainerResponse

Response object for Container operations

PartitionKeyRange
UniqueKey

Interface for a single unique key passed as part of UniqueKeyPolicy

UniqueKeyPolicy

Interface for setting unique keys on container creation

DatabaseDefinition
DatabaseResponse

Response object for Database operations

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>

ItemResponse
OfferDefinition
OfferResponse
PermissionBody
PermissionDefinition
PermissionResponse
Resource
StoredProcedureDefinition
StoredProcedureResponse
TriggerDefinition
TriggerResponse
UserDefinition
UserResponse
UserDefinedFunctionDefinition
UserDefinedFunctionResponse
Location

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

Document
IndexedPath
IndexingPolicy
PartitionKeyDefinition
IHeaders
SqlParameter

Represents a parameter in a Parameterized SQL query, specified in <xref:SqlQuerySpec>

SqlQuerySpec

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

IHeaders
CosmosResponse
ErrorResponse
FeedOptions

The feed options and query methods.

MediaOptions

Options associated with upload media.

RequestContext
RequestOptions

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

Response
IRetryPolicy
RetryContext
SessionContext

Type Aliases

PartitionKey

Enums

ConflictResolutionMode
ResourceType
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.

IndexKind

Specifies the supported Index types.

IndexingMode

Lazy

MediaReadMode

Enum for media read mode values.

PartitionKind
PermissionMode

Enum for permission mode values.

QueryCompatibilityMode
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

getHeaders(AuthOptions, IHeaders, string, string, string, string, RequestOptions | FeedOptions | MediaOptions, string, boolean)
addEntropy(string)
bulkDeleteItems(Container, any[], string)
bulkInsertItems(Container, any[])
bulkQueryItemsWithPartitionKey(Container, any[], any)
bulkReadItems(Container, any[], string)
bulkReplaceItems(Container, any[])
createOrUpsertItem(Container, any, RequestOptions, boolean)
createOrUpsertPermission(User, any, any, boolean)
createOrUpsertStoredProcedure(Container, any, any, boolean)
createOrUpsertTrigger(Container, any, any, boolean)
createOrUpsertUser(Database, any, any, boolean)
createOrUpsertUserDefinedFunction(Container, any, any, boolean)
getEntropy()
getTestContainer(string, CosmosClient, ContainerDefinition, RequestOptions)
getTestDatabase(string, CosmosClient)
removeAllDatabases(CosmosClient)
replaceOrUpsertItem(Container, any, RequestOptions, boolean)
replaceOrUpsertPermission(User, any, any, boolean)
replaceOrUpsertStoredProcedure(Container, any, any, boolean)
replaceOrUpsertTrigger(Container, any, any, boolean)
replaceOrUpsertUser(Database, any, any, boolean)
replaceOrUpsertUserDefinedFunction(Container, any, any, boolean)

Function Details

getHeaders(AuthOptions, IHeaders, string, string, string, string, RequestOptions | FeedOptions | MediaOptions, string, boolean)

function getHeaders(authOptions: AuthOptions, defaultHeaders: IHeaders, verb: string, path: string, resourceId: string, resourceType: string, options: RequestOptions | FeedOptions | MediaOptions, partitionKeyRangeId?: string, useMultipleWriteLocations?: boolean)

Parameters

authOptions
AuthOptions
defaultHeaders
IHeaders
verb
string
path
string
resourceId
string
resourceType
string
options
MediaOptions
partitionKeyRangeId
string
useMultipleWriteLocations
boolean

Returns

Promise<IHeaders>

addEntropy(string)

function addEntropy(name: string)

Parameters

name
string

Returns

string

bulkDeleteItems(Container, any[], string)

function bulkDeleteItems(container: Container, documents: any[], partitionKeyPropertyName: string)

Parameters

container
Container
documents
any[]
partitionKeyPropertyName
string

Returns

Promise<void>

bulkInsertItems(Container, any[])

function bulkInsertItems(container: Container, documents: any[])

Parameters

container
Container
documents
any[]

Returns

Resource>>

bulkQueryItemsWithPartitionKey(Container, any[], any)

function bulkQueryItemsWithPartitionKey(container: Container, documents: any[], partitionKeyPropertyName: any)

Parameters

container
Container
documents
any[]
partitionKeyPropertyName
any

Returns

Promise<void>

bulkReadItems(Container, any[], string)

function bulkReadItems(container: Container, documents: any[], partitionKey: string)

Parameters

container
Container
documents
any[]
partitionKey
string

Returns

Promise<void>

bulkReplaceItems(Container, any[])

function bulkReplaceItems(container: Container, documents: any[])

Parameters

container
Container
documents
any[]

Returns

Promise<any[]>

createOrUpsertItem(Container, any, RequestOptions, boolean)

function createOrUpsertItem(container: Container, body: any, options: RequestOptions, isUpsertTest: boolean)

Parameters

container
Container
body
any
options
RequestOptions
isUpsertTest
boolean

Returns

ItemResponse<any>>

createOrUpsertPermission(User, any, any, boolean)

function createOrUpsertPermission(user: User, body: any, options: any, isUpsertTest: boolean)

Parameters

user
User
body
any
options
any
isUpsertTest
boolean

Returns

createOrUpsertStoredProcedure(Container, any, any, boolean)

function createOrUpsertStoredProcedure(container: Container, body: any, options: any, isUpsertTest: boolean)

Parameters

container
Container
body
any
options
any
isUpsertTest
boolean

Returns

createOrUpsertTrigger(Container, any, any, boolean)

function createOrUpsertTrigger(container: Container, body: any, options: any, isUpsertTest: boolean)

Parameters

container
Container
body
any
options
any
isUpsertTest
boolean

Returns

Promise<TriggerResponse>

createOrUpsertUser(Database, any, any, boolean)

function createOrUpsertUser(database: Database, body: any, options: any, isUpsertTest: boolean)

Parameters

database
Database
body
any
options
any
isUpsertTest
boolean

Returns

Promise<UserResponse>

createOrUpsertUserDefinedFunction(Container, any, any, boolean)

function createOrUpsertUserDefinedFunction(container: Container, body: any, options: any, isUpsertTest: boolean)

Parameters

container
Container
body
any
options
any
isUpsertTest
boolean

Returns

getEntropy()

function getEntropy()

Returns

string

getTestContainer(string, CosmosClient, ContainerDefinition, RequestOptions)

function getTestContainer(testName: string, client?: CosmosClient, containerDef?: ContainerDefinition, options?: RequestOptions)

Parameters

testName
string
client
CosmosClient
containerDef
ContainerDefinition
options
RequestOptions

Returns

Promise<Container>

getTestDatabase(string, CosmosClient)

function getTestDatabase(testName: string, client?: CosmosClient)

Parameters

testName
string
client
CosmosClient

Returns

Promise<Database>

removeAllDatabases(CosmosClient)

function removeAllDatabases(client?: CosmosClient)

Parameters

client
CosmosClient

Returns

Promise<void>

replaceOrUpsertItem(Container, any, RequestOptions, boolean)

function replaceOrUpsertItem(container: Container, body: any, options: RequestOptions, isUpsertTest: boolean)

Parameters

container
Container
body
any
options
RequestOptions
isUpsertTest
boolean

Returns

ItemResponse<any>>

replaceOrUpsertPermission(User, any, any, boolean)

function replaceOrUpsertPermission(user: User, body: any, options: any, isUpsertTest: boolean)

Parameters

user
User
body
any
options
any
isUpsertTest
boolean

Returns

replaceOrUpsertStoredProcedure(Container, any, any, boolean)

function replaceOrUpsertStoredProcedure(container: Container, body: any, options: any, isUpsertTest: boolean)

Parameters

container
Container
body
any
options
any
isUpsertTest
boolean

Returns

replaceOrUpsertTrigger(Container, any, any, boolean)

function replaceOrUpsertTrigger(container: Container, body: any, options: any, isUpsertTest: boolean)

Parameters

container
Container
body
any
options
any
isUpsertTest
boolean

Returns

Promise<TriggerResponse>

replaceOrUpsertUser(Database, any, any, boolean)

function replaceOrUpsertUser(database: Database, body: any, options: any, isUpsertTest: boolean)

Parameters

database
Database
body
any
options
any
isUpsertTest
boolean

Returns

Promise<UserResponse>

replaceOrUpsertUserDefinedFunction(Container, any, any, boolean)

function replaceOrUpsertUserDefinedFunction(container: Container, body: any, options: any, isUpsertTest: boolean)

Parameters

container
Container
body
any
options
any
isUpsertTest
boolean

Returns