Class: DocumentClientWrapper

DocumentClientWrapper

new DocumentClientWrapper(urlConnection, auth, connectionPolicyopt, consistencyLevelopt)

Provides a wrapper for all the functions of DocumentClient that uses the Q module promise API instead of the callback model.
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 represent the consistency level. It can take any value from ConsistencyLevel.
Source:

Methods

createAttachmentAndUploadMediaAsync(documentLink, readableStream, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createAttachmentAsync(documentLink, body, optionsopt) → {Object}

Create an attachment for the document object.

Each document may contain zero or more attachemnts. 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 Attributes 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 <optional>
The request options.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createCollectionAsync(databaseLink, body, optionsopt) → {Object}

Create 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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createDatabaseAsync(body, optionsopt) → {Object}

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 represents The database to be created.
Properties
Name Type Description
id string The id of the database.
options RequestOptions <optional>
The request options.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createDocumentAsync(collectionOrDatabaseLink, body, optionsopt) → {Object}

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
collectionOrDatabaseLink string The collection link or database link if using a partition resolver
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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createPermissionAsync(userLink, body, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createStoredProcedureAsync(collectionLink, sproc, optionsopt) → {Object}

Create a StoredProcedure object.

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 represents The id of the stored procedure.
serverScript function represents the body of the stored procedure, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createTriggerAsync(collectionLink, trigger, optionsopt) → {Object}

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 represents The id of the trigger.
triggerType string represents the type of the trigger, should be one of the values of TriggerType.
triggerOperation string represents the trigger operation, should be one of the values of TriggerOperation.
serverScript function represents the body of the trigger, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createUserAsync(databaseLink, body, optionsopt) → {Object}

Create a 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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

createUserDefinedFunctionAsync(collectionLink, udf, optionsopt) → {Object}

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 represents 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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteAttachmentAsync(attachmentLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteCollectionAsync(collectionLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteConflictAsync(conflictLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteDatabaseAsync(databaseLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteDocumentAsync(documentLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deletePermissionAsync(permissionLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteStoredProcedureAsync(sprocLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteTriggerAsync(triggerLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteUserAsync(userLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

deleteUserDefinedFunctionAsync(udfLink, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

executeStoredProcedureAsync(sprocLink, paramsopt, optionsopt) → {Object}

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.
options Object <optional>
options for executing the stored procedure
Properties
Name Type Attributes Description
partitionKey Object <optional>
partition key value if executing against a partitioned collection
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type Response and the OnError callback takes a parameter of type ResponseError

Type
Object

getDatabaseAccountAsync() → {Object}

Gets the Database account information.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type DatabaseAccount and the OnError callback takes a parameter of type ResponseError

Type
Object

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>
Represents the feed options.
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

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

Query the documents for the collection.
Parameters:
Name Type Attributes Description
collectionOrDatabaseLink string The collection link or database link if using a partition resolver
query SqlQuerySpec | string A SQL query.
options FeedOptions <optional>
Represents the feed options.
Properties
Name Type Attributes Description
partitionKey object <optional>
Optional partition key to be used with the partiotion resolver
Source:
Returns:
- An instance of queryIterator to handle reading feed.
Type
QueryIterator

queryOffers(query, optionsopt) → {QueryIterator}

Query offers for this database.
Parameters:
Name Type Attributes Description
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

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

readAttachmentAsync(attachmentLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

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

readCollectionAsync(collectionLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

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

readConflictAsync(conflictLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

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

readDatabaseAsync(databaseLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

readDatabases(optionsopt) → {QueryIterator}

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

readDocumentAsync(documentLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

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

readMediaAsync(mediaLink) → {Object}

Read the media for the attachment object.
Parameters:
Name Type Description
mediaLink string The media link of the media in the attachment.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type Response and the OnError callback takes a parameter of type ResponseError

The result parameter can be a buffer or a stream depending on the value of MediaReadMode.

Type
Object

readOfferAsync(offerLink) → {Object}

Reads an offer object.
Parameters:
Name Type Description
offerLink string The self-link of the offer.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

readOffers(optionsopt) → {QueryIterator}

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

readPermissionAsync(permissionLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

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

readStoredProcedureAsync(sprocLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

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

readTriggerAsync(triggerLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

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

readUserAsync(userLink, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

readUserDefinedFunctionAsync(udfLink, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

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

replaceAttachmentAsync(attachmentLink, attachment, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

replaceCollectionAsync(collectionLink, collection, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

replaceDocumentAsync(documentLink, document, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

replaceOfferAsync(offerLink, offer) → {Object}

Replace the Offer object.
Parameters:
Name Type Description
offerLink string The self-link of the offer.
offer object Represent the new offer body.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

replacePermissionAsync(permissionLink, permission, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

replaceStoredProcedureAsync(sprocLink, sproc, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

replaceTriggerAsync(triggerLink, trigger, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

replaceUserAsync(userLink, user, optionsopt) → {Object}

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

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

replaceUserDefinedFunctionAsync(udfLink, udf, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

updateMediaAsync(mediaLink, readableStream, optionsopt) → {Object}

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
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

upsertAttachmentAndUploadMediaAsync(documentLink, readableStream, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

upsertAttachmentAsync(documentLink, body, optionsopt) → {Object}

Upsert an attachment for the document object.

Each document may contain zero or more attachemnts. 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 Attributes 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 <optional>
The request options.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

upsertDocumentAsync(collectionLink, body, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

upsertPermissionAsync(userLink, body, optionsopt) → {Object}

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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

upsertStoredProcedureAsync(collectionLink, sproc, optionsopt) → {Object}

Upsert a StoredProcedure object.

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 represents The id of the stored procedure.
serverScript function represents the body of the stored procedure, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

upsertTriggerAsync(collectionLink, trigger, optionsopt) → {Object}

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 represents The id of the trigger.
triggerType string represents the type of the trigger, should be one of the values of TriggerType.
triggerOperation string represents the trigger operation, should be one of the values of TriggerOperation.
serverScript function represents the body of the trigger, it can be passed as stringified too.
options RequestOptions <optional>
The request options.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

upsertUserAsync(databaseLink, body, optionsopt) → {Object}

Upsert a 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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object

upsertUserDefinedFunctionAsync(collectionLink, udf, optionsopt) → {Object}

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 represents 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.
Source:
Returns:

A promise object for the request completion.
The onFulfilled callback takes a parameter of type ResourceResponse and the OnError callback takes a parameter of type ResponseError

Type
Object