Class: DocumentClient

DocumentClient

new DocumentClient(urlConnection, auth, connectionPolicyopt, consistencyLevelopt)

Provides a client-side logical representation of the Azure DocumentDB database account. This client is used to configure and execute requests against the service.
Parameters:
Name Type Attributes Description
urlConnection string The service endpoint to use to create the client.
auth object An object that is used for authenticating requests and must contains one of the options
Properties
Name Type Attributes Description
masterkey string <optional>
The authorization master key to use to create the client.
resourceTokens Object <optional>
An object that contains resources tokens. Keys for the object are resource Ids and values are the resource tokens.
permissionFeed Array <optional>
An array of Permission objects.
connectionPolicy object <optional>
An instance of ConnectionPolicy class. This parameter is optional and the default connectionPolicy will be used if omitted.
consistencyLevel string <optional>
An optional parameter that represents the consistency level. It can take any value from ConsistencyLevel.
Source:

Methods

createAttachment(documentLink, body, options, callback)

Create an attachment for the document object.

Each document may contain zero or more attachments. Attachments can be of any MIME type - text, image, binary data.
These are stored externally in Azure Blob storage. Attachments are automatically deleted when the parent document is deleted.

Parameters:
Name Type Description
documentLink string The self-link of the document.
body Object The metadata the defines the attachment media like media, contentType. It can include any other properties as part of the metedata.
Properties
Name Type Description
contentType string The MIME contentType of the attachment.
media string Media link associated with the attachment content.
options RequestOptions The request options.
callback RequestCallback The callback for the request.
Source:

createAttachmentAndUploadMedia(documentLink, readableStream, optionsopt, callback)

Create an attachment for the document object.
Parameters:
Name Type Attributes Description
documentLink string The self-link of the document.
readableStream stream.Readable the stream that represents the media itself that needs to be uploaded.
options MediaOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

createCollection(databaseLink, body, optionsopt, callback)

Creates a collection.

A collection is a named logical container for documents.
A database may contain zero or more named collections and each collection consists of zero or more JSON documents.
Being schema-free, the documents in a collection do not need to share the same structure or fields.
Since collections are application resources, they can be authorized using either the master key or resource keys.

Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
body object Represents the body of the collection.
Properties
Name Type Description
id string The id of the collection.
indexingPolicy IndexingPolicy The indexing policy associated with the collection.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

createDatabase(body, optionsopt, callback)

Send a request for creating a database.

A database manages users, permissions and a set of collections.
Each Azure DocumentDB 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 collections, 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.

Parameters:
Name Type Attributes Description
body Object A json object that represents The database to be created.
Properties
Name Type Description
id string The id of the database.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

createDocument(collectionLink, body, optionsopt, callback)

Create a document.

There is no set schema for JSON documents. They may contain any number of custom properties as well as an optional list of attachments.
A Document is an application resource and can be authorized using the master key or resource keys

Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
body object Represents the body of the document. Can contain any number of user defined properties.
Properties
Name Type Attributes Description
id string <optional>
The id of the document, MUST be unique for each document.
options RequestOptions <optional>
The request options.
Properties
Name Type Attributes Description
disableAutomaticIdGeneration boolean <optional>
Disables the automatic id generation. If id is missing in the body and this option is true, an error will be returned.
callback RequestCallback The callback for the request.
Source:

createPermission(userLink, body, optionsopt, callback)

Create a permission.

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

Parameters:
Name Type Attributes Description
userLink string The self-link of the user.
body object Represents the body of the permission.
Properties
Name Type Description
id string The id of the permission
permissionMode string The mode of the permission, must be a value of PermissionMode
resource string The link of the resource that the permission will be applied to.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

createStoredProcedure(collectionLink, sproc, optionsopt, callback)

Create a StoredProcedure.

DocumentDB allows stored procedures to be executed in the storage tier, directly against a document collection. The script
gets executed under ACID transactions on the primary storage partition of the specified collection. For additional details,
refer to the server-side JavaScript API documentation.

Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
sproc object Represents the body of the stored procedure.
Properties
Name Type Description
id string The id of the stored procedure.
serverScript function The body of the stored procedure, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

createTrigger(collectionLink, trigger, optionsopt, callback)

Create a trigger.

DocumentDB supports pre and post triggers defined in JavaScript to be executed on creates, updates and deletes.
For additional details, refer to the server-side JavaScript API documentation.

Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
trigger object Represents the body of the trigger.
Properties
Name Type Description
id string The id of the trigger.
triggerType string The type of the trigger, should be one of the values of TriggerType.
triggerOperation string The trigger operation, should be one of the values of TriggerOperation.
serverScript function The body of the trigger, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

createUser(databaseLink, body, optionsopt, callback)

Create a database user.
Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
body object Represents the body of the user.
Properties
Name Type Description
id string The id of the user.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

createUserDefinedFunction(collectionLink, udf, optionsopt, callback)

Create a UserDefinedFunction.

DocumentDB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers.
For additional details, refer to the server-side JavaScript API documentation.

Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
udf object Represents the body of the userDefinedFunction.
Properties
Name Type Description
id string The id of the udf.
userDefinedFunctionType string The type of the udf, it should be one of the values of UserDefinedFunctionType
serverScript function Represents the body of the udf, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteAttachment(attachmentLink, optionsopt, callback)

Delete the attachment object.
Parameters:
Name Type Attributes Description
attachmentLink string The self-link of the attachment.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteCollection(collectionLink, optionsopt, callback)

Delete the collection object.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteConflict(conflictLink, optionsopt, callback)

Delete the conflict object.
Parameters:
Name Type Attributes Description
conflictLink string The self-link of the conflict.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteDatabase(databaseLink, optionsopt, callback)

Delete the database object.
Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteDocument(documentLink, optionsopt, callback)

Delete the document object.
Parameters:
Name Type Attributes Description
documentLink string The self-link of the document.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deletePermission(permissionLink, optionsopt, callback)

Delete the permission object.
Parameters:
Name Type Attributes Description
permissionLink string The self-link of the permission.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteStoredProcedure(sprocLink, optionsopt, callback)

Delete the StoredProcedure object.
Parameters:
Name Type Attributes Description
sprocLink string The self-link of the stored procedure.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteTrigger(triggerLink, optionsopt, callback)

Delete the trigger object.
Parameters:
Name Type Attributes Description
triggerLink string The self-link of the trigger.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteUser(userLink, optionsopt, callback)

Delete the user object.
Parameters:
Name Type Attributes Description
userLink string The self-link of the user.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

deleteUserDefinedFunction(udfLink, optionsopt, callback)

Delete the UserDefinedFunction object.
Parameters:
Name Type Attributes Description
udfLink string The self-link of the user defined function.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

executeStoredProcedure(sprocLink, paramsopt, callback)

Execute the StoredProcedure represented by the object.
Parameters:
Name Type Attributes Description
sprocLink string The self-link of the stored procedure.
params Array <optional>
represent the parameters of the stored procedure.
callback RequestCallback The callback for the request.
Source:

getDatabaseAccount(callback)

Gets the Database account information.
Parameters:
Name Type Description
callback RequestCallback The callback for the request. The second parameter of the callback will be of type DatabaseAccount.
Source:

queryAttachments(documentLink, query, optionsopt) → {QueryIterator}

Query the attachments for the document.
Parameters:
Name Type Attributes Description
documentLink string The self-link of the document.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryCollections(databaseLink, query, optionsopt) → {QueryIterator}

Query the collections for the database.
Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryConflicts(collectionLink, query, optionsopt) → {QueryIterator}

Query the conflicts for the collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryDatabases(query, optionsopt) → {QueryIterator}

Lists all databases that satisfy a query.
Parameters:
Name Type Attributes Description
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of QueryIterator to handle reading feed.
Type
QueryIterator

queryDocuments(collectionLink, query, optionsopt) → {QueryIterator}

Query the documents for the collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryOffers(query, optionsopt) → {QueryIterator}

Lists all offers that satisfy a query.
Parameters:
Name Type Attributes Description
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of QueryIterator to handle reading feed.
Type
QueryIterator

queryPermissions(userLink, query, optionsopt) → {QueryIterator}

Query the permission for the user.
Parameters:
Name Type Attributes Description
userLink string The self-link of the user.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryStoredProcedures(collectionLink, query, optionsopt) → {QueryIterator}

Query the storedProcedures for the collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryTriggers(collectionLink, query, optionsopt) → {QueryIterator}

Query the triggers for the collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryUserDefinedFunctions(collectionLink, query, optionsopt) → {QueryIterator}

Query the user defined functions for the collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryUsers(databaseLink, query, optionsopt) → {QueryIterator}

Query the users for the database.
Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readAttachment(attachmentLink, optionsopt, callback)

Reads an Attachment object.
Parameters:
Name Type Attributes Description
attachmentLink string The self-link of the attachment.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readAttachments(documentLink, optionsopt) → {QueryIterator}

Get all attachments for this document.
Parameters:
Name Type Attributes Description
documentLink string The self-link of the document.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readCollection(collectionLink, optionsopt, callback)

Reads a collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readCollections(databaseLink, optionsopt) → {QueryIterator}

Get all collections in this database.
Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readConflict(conflictLink, optionsopt, callback)

Reads a conflict.
Parameters:
Name Type Attributes Description
conflictLink string The self-link of the conflict.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readConflicts(collectionLink, optionsopt) → {QueryIterator}

Get all conflicts in this collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of QueryIterator to handle reading feed.
Type
QueryIterator

readDatabase(databaseLink, optionsopt, callback)

Reads a database.
Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readDatabases(optionsopt) → {QueryIterator}

Lists all databases.
Parameters:
Name Type Attributes Description
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readDocument(documentLink, optionsopt, callback)

Reads a document.
Parameters:
Name Type Attributes Description
documentLink string The self-link of the document.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readDocuments(collectionLink, optionsopt) → {QueryIterator}

Get all documents in this collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readMedia(mediaLink, callback)

Read the media for the attachment object.
Parameters:
Name Type Description
mediaLink string The media link of the media in the attachment.
callback RequestCallback The callback for the request, the result parameter can be a buffer or a stream depending on the value of MediaReadMode.
Source:

readOffer(offerLink, callback)

Reads an offer.
Parameters:
Name Type Description
offerLink string The self-link of the offer.
callback RequestCallback The callback for the request.
Source:

readOffers(optionsopt) → {QueryIterator}

Lists all offers.
Parameters:
Name Type Attributes Description
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readPermission(permissionLink, optionsopt, callback)

Reads a permission.
Parameters:
Name Type Attributes Description
permissionLink string The self-link of the permission.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readPermissions(userLink, feedOptionsopt) → {QueryIterator}

Get all permissions for this user.
Parameters:
Name Type Attributes Description
userLink string The self-link of the user.
feedOptions FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readStoredProcedure(sprocLink, optionsopt, callback)

Reads a StoredProcedure object.
Parameters:
Name Type Attributes Description
sprocLink string The self-link of the stored procedure.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readStoredProcedures(collectionLink, optionsopt) → {QueryIterator}

Get all StoredProcedures in this collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readTrigger(triggerLink, optionsopt, callback)

Reads a trigger object.
Parameters:
Name Type Attributes Description
triggerLink string The self-link of the trigger.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readTriggers(collectionLink, optionsopt) → {QueryIterator}

Get all triggers in this collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readUser(userLink, optionsopt, callback)

Reads a user.
Parameters:
Name Type Attributes Description
userLink string The self-link of the user.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readUserDefinedFunction(udfLink, optionsopt, callback)

Reads a udf object.
Parameters:
Name Type Attributes Description
udfLink string The self-link of the user defined function.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

readUserDefinedFunctions(collectionLink, optionsopt) → {QueryIterator}

Get all UserDefinedFunctions in this collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
options FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

readUsers(databaseLink, feedOptionsopt) → {QueryIterator}

Get all users in this database.
Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
feedOptions FeedOptions <optional>
The feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

replaceAttachment(attachmentLink, attachment, optionsopt, callback)

Replace the attachment object.
Parameters:
Name Type Attributes Description
attachmentLink string The self-link of the attachment.
attachment object Represent the new attachment body.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

replaceCollection(collectionLink, collection, optionsopt, callback)

Replace the document collection.
Parameters:
Name Type Attributes Description
collectionLink string The self-link of the document collection.
collection object Represent the new document collection body.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

replaceDocument(documentLink, document, optionsopt, callback)

Replace the document object.
Parameters:
Name Type Attributes Description
documentLink string The self-link of the document.
document object Represent the new document body.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

replaceOffer(offerLink, offer, callback)

Replace the offer object.
Parameters:
Name Type Description
offerLink string The self-link of the offer.
offer object Represent the new offer body.
callback RequestCallback The callback for the request.
Source:

replacePermission(permissionLink, permission, optionsopt, callback)

Replace the permission object.
Parameters:
Name Type Attributes Description
permissionLink string The self-link of the permission.
permission object Represent the new permission body.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

replaceStoredProcedure(sprocLink, sproc, optionsopt, callback)

Replace the StoredProcedure object.
Parameters:
Name Type Attributes Description
sprocLink string The self-link of the stored procedure.
sproc object Represent the new sproc body.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

replaceTrigger(triggerLink, trigger, optionsopt, callback)

Replace the trigger object.
Parameters:
Name Type Attributes Description
triggerLink string The self-link of the trigger.
trigger object Represent the new trigger body.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

replaceUser(userLink, user, optionsopt, callback)

Replace the user object.
Parameters:
Name Type Attributes Description
userLink string The self-link of the user.
user object Represent the new user body.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

replaceUserDefinedFunction(udfLink, udf, optionsopt, callback)

Replace the UserDefinedFunction object.
Parameters:
Name Type Attributes Description
udfLink string The self-link of the user defined function.
udf object Represent the new udf body.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

updateMedia(mediaLink, readableStream, optionsopt, callback)

Update media for the attachment
Parameters:
Name Type Attributes Description
mediaLink string The media link of the media in the attachment.
readableStream stream.Readable The stream that represents the media itself that needs to be uploaded.
options MediaOptions <optional>
options for the media
callback RequestCallback The callback for the request.
Source:

upsertAttachment(documentLink, body, options, callback)

Upsert an attachment for the document object.

Each document may contain zero or more attachments. Attachments can be of any MIME type - text, image, binary data.
These are stored externally in Azure Blob storage. Attachments are automatically deleted when the parent document is deleted.

Parameters:
Name Type Description
documentLink string The self-link of the document.
body Object The metadata the defines the attachment media like media, contentType. It can include any other properties as part of the metedata.
Properties
Name Type Description
contentType string The MIME contentType of the attachment.
media string Media link associated with the attachment content.
options RequestOptions The request options.
callback RequestCallback The callback for the request.
Source:

upsertAttachmentAndUploadMedia(documentLink, readableStream, optionsopt, callback)

Upsert an attachment for the document object.
Parameters:
Name Type Attributes Description
documentLink string The self-link of the document.
readableStream stream.Readable the stream that represents the media itself that needs to be uploaded.
options MediaOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

upsertDocument(collectionLink, body, optionsopt, callback)

Upsert a document.

There is no set schema for JSON documents. They may contain any number of custom properties as well as an optional list of attachments.
A Document is an application resource and can be authorized using the master key or resource keys

Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
body object Represents the body of the document. Can contain any number of user defined properties.
Properties
Name Type Attributes Description
id string <optional>
The id of the document, MUST be unique for each document.
options RequestOptions <optional>
The request options.
Properties
Name Type Attributes Description
disableAutomaticIdGeneration boolean <optional>
Disables the automatic id generation. If id is missing in the body and this option is true, an error will be returned.
callback RequestCallback The callback for the request.
Source:

upsertPermission(userLink, body, optionsopt, callback)

Upsert a permission.

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

Parameters:
Name Type Attributes Description
userLink string The self-link of the user.
body object Represents the body of the permission.
Properties
Name Type Description
id string The id of the permission
permissionMode string The mode of the permission, must be a value of PermissionMode
resource string The link of the resource that the permission will be applied to.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

upsertStoredProcedure(collectionLink, sproc, optionsopt, callback)

Upsert a StoredProcedure.

DocumentDB allows stored procedures to be executed in the storage tier, directly against a document collection. The script
gets executed under ACID transactions on the primary storage partition of the specified collection. For additional details,
refer to the server-side JavaScript API documentation.

Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
sproc object Represents the body of the stored procedure.
Properties
Name Type Description
id string The id of the stored procedure.
serverScript function The body of the stored procedure, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

upsertTrigger(collectionLink, trigger, optionsopt, callback)

Upsert a trigger.

DocumentDB supports pre and post triggers defined in JavaScript to be executed on creates, updates and deletes.
For additional details, refer to the server-side JavaScript API documentation.

Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
trigger object Represents the body of the trigger.
Properties
Name Type Description
id string The id of the trigger.
triggerType string The type of the trigger, should be one of the values of TriggerType.
triggerOperation string The trigger operation, should be one of the values of TriggerOperation.
serverScript function The body of the trigger, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

upsertUser(databaseLink, body, optionsopt, callback)

Upsert a database user.
Parameters:
Name Type Attributes Description
databaseLink string The self-link of the database.
body object Represents the body of the user.
Properties
Name Type Description
id string The id of the user.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source:

upsertUserDefinedFunction(collectionLink, udf, optionsopt, callback)

Upsert a UserDefinedFunction.

DocumentDB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers.
For additional details, refer to the server-side JavaScript API documentation.

Parameters:
Name Type Attributes Description
collectionLink string The self-link of the collection.
udf object Represents the body of the userDefinedFunction.
Properties
Name Type Description
id string The id of the udf.
userDefinedFunctionType string The type of the udf, it should be one of the values of UserDefinedFunctionType
serverScript function Represents the body of the udf, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
callback RequestCallback The callback for the request.
Source: