Class: Collection

Collection()

new Collection()

Stored procedures and triggers are registered for a particular collection. The Collection object supports create, read, update and delete (CRUD) and query operations on documents and attachments in the current collection.
All collection operations are completed asynchronously. You can provide a callback to handle the result of the operation, and to perform error handling if necessary.
Stored procedures and triggers are executed in a time-limited manner. Long-running stored procedures and triggers are defensively timed out and all transactions performed are rolled back.
We stop queuing collection operations if the stored procedure is close to timing out. You can inspect the boolean return value of all collection operations to see if an operation was not queued and handle this situation gracefully.

Source:

Members

(static) ErrorCodes :number

List of error codes returned by database operations in the RequestCallback and FeedCallback. See the corresponding error message for more details.
Type:
  • number
Properties:
Name Type Description
BadRequest number (400) Request failed due to bad inputs
Forbidden number (403) Request was denied access to the resource
NotFound number (404) Request tried to access a resource which doesn't exist
Conflict number (409) Resource with the specified id already exists
PreconditionFailed number (412) Conditions specified in the request options were not met
RequestEntityTooLarge number (413) Request failed because it was too large
RetryWith number (449) Request conflicted with the current state of a resource and must be retried from a new transaction from the client side
InternalServerError number (500) Server encountered an unexpected error in processing the request
Source:

Methods

chain() → {Collection.QueryResponse}

Opening call to start a chained query. Should be used in conjunction with the closing value call to perform chained queries.
Source:
See:
Returns:
- Response which contains whether or not the query was accepted. Can be used in a chained call to call further queries.
Type
Collection.QueryResponse
Example
var name = "John";
var result = __.chain()
    .filter(function(doc) { return doc.name == name; })
    .map(function(doc) { return { name: doc.name, age: doc.age }; })
    .value();
if(!result.isAccepted) throw new Error("The call was not accepted");

createAttachment(documentLink, body, optionsopt, callbackopt) → {Boolean}

Create an attachment for the document.
Parameters:
Name Type Attributes Description
documentLink string resource link of the document under which the attachment will be created
body Object

metadata that defines the attachment media like media, contentType
It can include any other properties as part of the metedata.

Properties
Name Type Description
contentType string MIME contentType of the attachment
media string media link associated with the attachment content
options Collection.CreateOptions <optional>
optional create options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the create has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

createDocument(collectionLink, body, optionsopt, callbackopt) → {Boolean}

Create a document under the collection.
Parameters:
Name Type Attributes Description
collectionLink string resource link of the collection under which the document will be created
body Object

body of the document
The "id" property is required and will be generated automatically if not provided (this behaviour can be overriden using the CreateOptions). Any other properties can be added.

options Collection.CreateOptions <optional>
optional create options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the create has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

deleteAttachment(attachmentLink, optionsopt, callbackopt) → {Boolean}

Delete an attachment.
Parameters:
Name Type Attributes Description
attachmentLink string resource link of the attachment to be deleted
options Collection.DeleteOptions <optional>
optional delete options.
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the delete has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

deleteDocument(documentLink, optionsopt, callbackopt) → {Boolean}

Delete a document.
Parameters:
Name Type Attributes Description
documentLink string resource link of the document to delete
options Collection.DeleteOptions <optional>
optional delete options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the delete has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

filter(predicate, optionsopt, callbackopt) → {Collection.QueryResponse}

Execute a filter on the input stream of documents, resulting in a subset of the input stream that matches the given filter.
When filter is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function.

Parameters:
Name Type Attributes Description
predicate Collection.FilterPredicate Predicate function defining the filter
options Collection.FeedOptions <optional>
Optional query options. Should not be used in a chained call.
callback Collection.FeedCallback <optional>

Optional callback for the operation.
If no callback is provided, any error in the operation will be thrown
and the result document set will be written to the Response body.
Should not be used in a chained call.

Source:
Returns:
- Response which contains whether or not the query was accepted. Can be used in a chained call to call further queries.
Type
Collection.QueryResponse
Example
// Example 1: get documents(people) with age < 30.
var result = __.filter(function(doc) { return doc.age < 30; });
if(!result.isAccepted) throw new Error("The call was not accepted");

// Example 2: get documents (people) with age < 30 and select only name.
var result = __.chain()
    .filter(function(doc) { return doc.age < 30; })
    .pluck("name")
    .value();
if(!result.isAccepted) throw new Error("The call was not accepted");

// Example 3: get document (person) with id = 1 and delete it.
var result = __.filter(function(doc) { return doc.id === 1; }, function(err, feed, options) {
    if(err) throw err;
    if(!__.deleteDocument(feed[0].getSelfLink())) throw new Error("deleteDocument was not accepted");
});
if(!result.isAccepted) throw new Error("The call was not accepted");

flatten(isShallowopt, optionsopt, callbackopt) → {Collection.QueryResponse}

Flatten nested arrays from each document in the input document stream.
When flatten is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function.

Parameters:
Name Type Attributes Description
isShallow Boolean <optional>
If true, flattens only the first level of nested arrays (false by default)
options Collection.FeedOptions <optional>
Optional query options. Should not be used in a chained call.
callback Collection.FeedCallback <optional>

Optional callback for the operation.
If no callback is provided, any error in the operation will be thrown
and the result document set will be written to the Response body.
Should not be used in a chained call.

Source:
Returns:
- Response which contains whether or not the query was accepted. Can be used in a chained call to call further queries.
Type
Collection.QueryResponse
Example
// Get documents (people) with age < 30, select tags (an array property)
// and flatten the result into one array for all documents.
var result = __.chain()
    .filter(function(doc) { return doc.age < 30; })
    .map(function(doc) { return doc.tags; })
    .flatten()
    .value();
if(!result.isAccepted) throw new Error("The call was not accepted");
Get alt link (name-based link) of current collection.
Source:
Returns:
Alt link of current collection.
Type
string
Get self link of current collection.
Source:
Returns:
Self link of current collection.
Type
string

map(predicate, optionsopt, callbackopt) → {Collection.QueryResponse}

Produce a new set of documents by mapping/projecting the properties of the documents in the input document stream through the given mapping predicate.
When map is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function.

Parameters:
Name Type Attributes Description
predicate Collection.ProjectionPredicate Predicate function defining the projection
options Collection.FeedOptions <optional>
Optional query options. Should not be used in a chained call.
callback Collection.FeedCallback <optional>

Optional callback for the operation.
If no callback is provided, any error in the operation will be thrown
and the result document set will be written to the Response body.
Should not be used in a chained call.

Source:
Returns:
- Response which contains whether or not the query was accepted. Can be used in a chained call to call further queries.
Type
Collection.QueryResponse
Example
// Example 1: select only name and age for each document (person).
var result = __.map(function(doc){ return { name: doc.name, age: doc.age}; });
if(!result.isAccepted) throw new Error("The call was not accepted");

// Example 2: select name and age for each document (person), and return only people with age < 30.
var result = __.chain()
    .map(function(doc) { return { name: doc.name, age: doc.age}; })
    .filter(function(doc) { return doc.age < 30; })
    .value();
if(!result.isAccepted) throw new Error("The call was not accepted");

pluck(propertyName, optionsopt, callbackopt) → {Collection.QueryResponse}

Produce a new set of documents by extracting a single property from each document in the input document stream. This is equivalent to a map call that projects only propertyName.
When pluck is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function.

Parameters:
Name Type Attributes Description
propertyName string Name of the property to pluck from all documents in the current collection
options Collection.FeedOptions <optional>
Optional query options. Should not be used in a chained call.
callback Collection.FeedCallback <optional>

Optional callback for the operation.
If no callback is provided, any error in the operation will be thrown
and the result document set will be written to the Response body.
Should not be used in a chained call.

Source:
Returns:
- Response which contains whether or not the query was accepted. Can be used in a chained call to call further queries.
Type
Collection.QueryResponse
Example
// Get documents (people) with age < 30 and select only name.
var result = __.chain()
    .filter(function(doc) { return doc.age < 30; })
    .pluck("name")
    .value();
if(!result.isAccepted) throw new Error("The call was not accepted");

queryAttachments(documentLink, query, optionsopt, callbackopt) → {Boolean}

Execute a SQL query on the attachments for the document.
Parameters:
Name Type Attributes Description
documentLink string resource link of the document whose attachments are being queried
query string SQL query string. This can also be a JSON object to pass in a parameterized query along with the values.
options Collection.FeedOptions <optional>
optional query options
callback Collection.FeedCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the query has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

queryDocuments(collectionLink, filterQuery, optionsopt, callbackopt) → {Boolean}

Execute a SQL query on the documents of the collection.
Parameters:
Name Type Attributes Description
collectionLink string resource link of the collection whose documents are being queried
filterQuery string SQL query string. This can also be a JSON object to pass in a parameterized query along with the values.
options Collection.FeedOptions <optional>
optional query options.
callback Collection.FeedCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the query has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

readAttachment(attachmentLink, optionsopt, callbackopt) → {Boolean}

Read an Attachment.
Parameters:
Name Type Attributes Description
attachmentLink string resource link of the attachment to read
options Collection.ReadOptions <optional>
optional read options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the read has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

readAttachments(documentLink, optionsopt, callbackopt) → {Boolean}

Get all attachments for the document.
Parameters:
Name Type Attributes Description
documentLink string resource link of the document whose attachments are being read
options Collection.FeedOptions <optional>
optional read feed options
callback Collection.FeedCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the read has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

readDocument(documentLink, optionsopt, callbackopt) → {Boolean}

Read a document.
Parameters:
Name Type Attributes Description
documentLink string resource link of the document to read
options Collection.ReadOptions <optional>
optional read options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the read has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

readDocuments(collectionLink, optionsopt, callbackopt) → {Boolean}

Get all documents for the collection.
Parameters:
Name Type Attributes Description
collectionLink string resource link of the collection whose documents are being read
options Collection.FeedOptions <optional>
optional read feed options
callback Collection.FeedCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the read has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

replaceAttachment(attachmentLink, attachment, optionsopt, callbackopt) → {Boolean}

Replace an attachment.
Parameters:
Name Type Attributes Description
attachmentLink string resource link of the attachment to be replaced
attachment Object new attachment body
options Colleciton.ReplaceOptions <optional>
optional replace options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the replace has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

replaceDocument(documentLink, document, optionsopt, callbackopt) → {Boolean}

Replace a document.
Parameters:
Name Type Attributes Description
documentLink string resource link of the document
document Object new document body
options Colleciton.ReplaceOptions <optional>
optional replace options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the replace has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

sortBy(predicate, optionsopt, callbackopt) → {Collection.QueryResponse}

Produce a new set of documents by sorting the documents in the input document stream in ascending order using the given predicate.
When sortBy is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function.

Parameters:
Name Type Attributes Description
predicate Collection.SortByPredicate Predicate function defining the property to sort by.
options Collection.FeedOptions <optional>
Optional query options. Should not be used in a chained call.
callback Collection.FeedCallback <optional>

Optional callback for the operation.
If no callback is provided, any error in the operation will be thrown
and the result document set will be written to the Response body.
Should not be used in a chained call.

Source:
See:
Returns:
- Response which contains whether or not the query was accepted. Can be used in a chained call to call further queries.
Type
Collection.QueryResponse
Example
// Example 1: sort documents (people) by age
var result = __.sortBy(function(doc){ return doc.age; })
if(!result.isAccepted) throw new Error("The call was not accepted");

// Example 2: sortBy in a chain by name
var result = __.chain()
    .filter(function(doc) { return doc.age < 30; })
    .sortBy(function(doc) { return doc.name; })
    .value();
if(!result.isAccepted) throw new Error("The call was not accepted");

sortByDescending(predicate, optionsopt, callbackopt) → {Collection.QueryResponse}

Produce a new set of documents by sorting the documents in the input document stream in descending order using the given predicate.
When sortByDescending is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function.

Parameters:
Name Type Attributes Description
predicate Collection.SortByPredicate Predicate function defining the property to sort by.
options Collection.FeedOptions <optional>
Optional query options. Should not be used in a chained call.
callback Collection.FeedCallback <optional>

Optional callback for the operation.
If no callback is provided, any error in the operation will be thrown
and the result document set will be written to the Response body.
Should not be used in a chained call.

Source:
See:
  • sortBy to sort in ascending order.
Returns:
- Response which contains whether or not the query was accepted. Can be used in a chained call to call further queries.
Type
Collection.QueryResponse
Example
// Example 1: sort documents (people) by age in descending order
var result = __.sortByDescending(function(doc) { return doc.age; })
if(!result.isAccepted) throw new Error("The call was not accepted");

// Example 2: sortBy in a chain by name in descending order
var result = __.chain()
    .filter(function(doc) { return doc.age < 30; })
    .sortByDescending(function(doc) { return doc.name; })
    .value();
if(!result.isAccepted) throw new Error("The call was not accepted");

unwind(innerCollectionSelector, resultSelectoropt, optionsopt, callbackopt) → {Collection.QueryResponse}

Perfoms a join with inner collection with both top level document item and inner collection item added to the result projection.
When resultSelector is provided, resultSelector is called for each pair of <current document, inner collection item>.

When resultSelector is not provided, __.unwind() just adds inner collection to the result projection. In this case unwind() is equivalent to map(innerCollectionSelector).flatten(). Calls to unwind can be chained to perform multiple joins.
Parameters:
Name Type Attributes Description
innerCollectionSelector Collection.ProjectionPredicate Predicate function defining the projection for inner collection.
resultSelector Collection.ResultSelectorPredicate <optional>
Optional predicate> function defining result projection.
options Collection.FeedOptions <optional>
Optional query options. Should not be used in a chained call.
callback Collection.FeedCallback <optional>

Optional callback for the operation.
If no callback is provided, any error in the operation will be thrown
and the result document set will be written to the Response body.
Should not be used in a chained call.

Source:
Returns:
- Response which contains whether or not the query was accepted. Can be used in a chained call to call further queries.
Type
Collection.QueryResponse
Example
// Get <customer, kids, pet> tuples from customer collection:
//
var result = __.chain()
      .unwind(c => c.kids, (c, k) => { return { customer: c, kid: k } })
      .unwind(ck => ck.kid.pets, (ck, p) => { return { customer: ck.customer.name, kid: ck.kid.name, pet: p.name }})
      .value();
if(!result.isAccepted) throw new Error("one of the calls was not accepted");
//
// With the following input data:
// [{
//         "id": "1",
//         "name": "Alex",
//         "kids": [{
//                 "name": "Bob",
//                 "pets": [
//                     { "name": "Chucky" },
//                     { "name": "Chauncey" },
//                 ]
//             },
//             {
//                 "name": "Bill",
//                 "pets": [
//                     { "name": "Charcoral" },
//                     { "name": "Cookie" }
//                 ]
//             }
//         ]
//     },
//     {
//         "id": "2",
//         "name": "Alice",
//         "kids": [{
//                 "name": "Barbara",
//                 "pets": [
//                     { "name": "Copper" },
//                     { "name": "Curly" }
//                 ]
//             },
//             {
//                 "name": "Beth",
//                 "pets": [
//                     { "name": "Cutie" }
//                 ]
//             }
//         ]
//     }
// ]
//
// The result would be:
//
// [
//     { "customer": "Alex", "kid": "Bob", "pet": "Chucky" },
//     { "customer": "Alex", "kid": "Bob", "pet": "Chauncey" },
//     { "customer": "Alex", "kid": "Bill", "pet": "Charcoral" },
//     { "customer": "Alex", "kid": "Bill", "pet": "Cookie" },
//     { "customer": "Alice", "kid": "Barbara", "pet": "Copper" },
//     { "customer": "Alice", "kid": "Barbara", "pet": "Curly" },
//     { "customer": "Alice", "kid": "Beth", "pet": "Cutie" }
// ]
//
// This is equivalent to:
// SELECT
//   c.name as customer,
//   k.name as kid,
//   p.name as pet
// FROM customer c
// JOIN k in c.kids
// JOIN p in k.pets

upsertAttachment(documentLink, body, optionsopt, callbackopt) → {Boolean}

Upsert an attachment for the document.
Parameters:
Name Type Attributes Description
documentLink string resource link of the document under which the attachment will be upserted
body Object

metadata that defines the attachment media like media, contentType
It can include any other properties as part of the metedata.

Properties
Name Type Description
contentType string MIME contentType of the attachment
media string media link associated with the attachment content
options Collection.UpsertOptions <optional>
optional upsert options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the upsert has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

upsertDocument(collectionLink, body, optionsopt, callbackopt) → {Boolean}

Upsert a document under the collection.
Parameters:
Name Type Attributes Description
collectionLink string resource link of the collection under which the document will be upserted
body Object

body of the document
The "id" property is required and will be generated automatically if not provided (this behaviour can be overriden using the UpsertOptions). Any other properties can be added.

options Collection.UpsertOptions <optional>
optional upsert options
callback Collection.RequestCallback <optional>

optional callback for the operation
If no callback is provided, any error in the operation will be thrown.

Source:
Returns:
True if the upsert has been queued, false if it is not queued because of a pending timeout.
Type
Boolean

value(optionsopt, callbackopt) → {Collection.QueryResponse}

Terminating call for a chained query. Should be used in conjunction with the opening chain call to perform chained queries.
When value is called, the query is queued for execution with the given options and callback.

Parameters:
Name Type Attributes Description
options Collection.FeedOptions <optional>
Optional query options for the entire chained call.
callback Collection.FeedCallback <optional>

Optional callback for the operation
If no callback is provided, any error in the operation will be thrown
and the result document set will be written to the Response body.

Source:
See:
Returns:
- Response which contains whether or not the query was accepted.
Type
Collection.QueryResponse
Example
// Example 1: use defaults: the result goes to the response body.
__.chain()
    .filter(function(doc) { return doc.name == "John"; })
    .pluck("age"))
    .value();
if(!result.isAccepted) throw new Error("The call was not accepted");

// Example 2: use options and callback.
function(continuationToken) {
    var result = __.chain()
        .filter(function(doc) { return doc.name == "John"; })
        .pluck("age"))
        .value({continuation: continuationToken}, function(err, feed, options) {
            if(err) throw err;
            __response.setBody({
                result: feed,
                continuation: options.continuation
            });
        });
    if(!result.isAccepted) throw new Error("The call was not accepted");
}

Type Definitions

CreateOptions

Options associated with a create operation.
Type:
  • Object
Properties:
Name Type Attributes Description
indexAction string <optional>
Specifies indexing directives.
Properties
Name Type Description
default string use the default indexing policy specified for this collection
include string include this document in the index
exclude string exclude this document from the index
disableAutomaticIdGeneration string <optional>
Disables automatic generation of "id" field of the document to be created (if it is not provided)
Source:

DeleteOptions

Options associated with a delete operation.
Type:
  • Object
Properties:
Name Type Attributes Description
etag string <optional>

The entity tag associated with the resource.
This is matched with the persisted resource before deletion.

Source:

FeedCallback(error, resources, options)

The callback to execute after completion of read feed or query request.
Parameters:
Name Type Description
error Object Will contain error information if an error occurs, undefined otherwise.
Properties
Name Type Description
number ErrorCodes The HTTP response code corresponding to the error.
body string A string containing the error information.
resources Array

An array or resources (documents or attachments) that was read.
This is undefined if an error occurs in the operation.

options Object Information associated with the response to the operation.
Properties
Name Type Description
continuation string Opaque token for continuing the read feed or query.
currentCollectionSizeInMB string Comma delimited string containing the collection's current quota metrics (storage, number of stored procedure, triggers and UDFs) after completion of the operation.
maxCollectionSizeInMB string Comma delimited string containing the collection's maximum quota metrics (storage, number of stored procedure, triggers and UDFs).
Source:

FeedOptions

Options associated with a read feed or query operation.
Type:
  • Object
Properties:
Name Type Attributes Description
pageSize Number <optional>

Max number of items to be returned in the enumeration operation.
Value is 100 by default

continuation string <optional>
Opaque token for continuing the enumeration.
enableScan Boolean <optional>
Allow scan on the queries which couldn't be served as indexing was opted out on the requested paths (only for queryDocuments() and queryAttachments())
enableLowPrecisionOrderBy Boolean <optional>
Allow order by with low precision (only for queryDocuments(), sortBy() and sortByDescending)
Source:

FilterPredicate(document) → {Boolean}

The predicate function for a filter query, which acts as a truth test of whether a document should be filtered or not.
Parameters:
Name Type Description
document Object Input document.
Source:
See:
Returns:
- True if this document matches the filter, false otherwise. If true, this document will be added to the output result of the filter call.
Type
Boolean
Example
function(doc) { return doc.age < 30; }

ProjectionPredicate(document) → {Object}

The predicate function for a map/projection, unwind/innerCollectionSelector, which maps the input document's properties into a new document object.
Parameters:
Name Type Description
document Object Input document.
Source:
See:
  • The map call.
Returns:
- Output document, containing only the mapped properties. This output document will be added to the output result of the map call.
Type
Object
Example
function(doc) { return { name: doc.name, age: doc.age }; }

QueryResponse

Object returned from a query function, namely chain, filter, map, pluck, flatten, or value.
If the query is part of a chained call, then this object can be used to chain further queries until the final terminating value call.

Type:
  • Object
Properties:
Name Type Description
isAccepted Boolean True if the query has been queued, false if it is not queued because of a pending timeout.
Source:

ReadOptions

Options associated with a read operation.
Type:
  • Object
Properties:
Name Type Attributes Description
ifNoneMatch string <optional>
The conditional HTTP method ifNoneMatch value.
Source:

ReplaceOptions

Options associated with a replace operation.
Type:
  • Object
Properties:
Name Type Attributes Description
indexAction string <optional>
Specifies indexing directives.
Properties
Name Type Description
default string use the default indexing policy specified for this collection
include string include this document in the index
exclude string exclude this document from the index
etag string <optional>

The entity tag associated with the resource.
This is matched with the persisted resource before deletion.

Source:

RequestCallback(error, resource, options)

Callback to execute after completion of a request.
Parameters:
Name Type Description
error Object Will contain error information if an error occurs, undefined otherwise.
Properties
Name Type Description
number ErrorCodes The HTTP response code corresponding to the error.
body string A string containing the error information.
resource Object

An object that represents the requested resource (document or attachment).
This is undefined if an error occurs in the operation.

options Object Information associated with the response to the operation.
Properties
Name Type Description
currentCollectionSizeInMB string Comma delimited string containing the collection's current quota metrics (storage, number of stored procedure, triggers and UDFs) after completion of the operation.
maxCollectionSizeInMB string Comma delimited string containing the collection's maximum quota metrics (storage, number of stored procedure, triggers and UDFs).
notModified Boolean Set to true if the requested resource has not been modified compared to the provided ETag in the ifNoneMatch parameter for a read request.
Object
Source:

ResultSelectorPredicate(documentItem, innerCollectionItem) → {Object}

The predicate function for a unwind/resultSelector, which maps the input document's properties into a new document object.
Parameters:
Name Type Description
documentItem Object Input document or top level item from previous projection.
innerCollectionItem Object The item selected from inner collection.
Source:
See:
Returns:
- Output document, containing only the mapped properties. This output document will be added to the output result of the map call.
Type
Object
Example
function(customer, child) { return { customerName: customer.name, childName: child.name }; }

SortByPredicate(document) → {String/Number}

The predicate function for a sortBy or a sortByDescending query, which defines the property of the document to be used for sorting.
Parameters:
Name Type Description
document Object Input document.
Source:
See:
Returns:
- A property of the document to use for sorting.
Type
String/Number
Example
// Sort the documents by the 'name' property.
function(doc){ return doc.name; }

UpsertOptions

Options associated with a upsert operation.
Type:
  • Object
Properties:
Name Type Attributes Description
indexAction string <optional>
Specifies indexing directives.
Properties
Name Type Description
default string use the default indexing policy specified for this collection
include string include this document in the index
exclude string exclude this document from the index
disableAutomaticIdGeneration string <optional>
Disables automatic generation of "id" field of the document to be upserted (if it is not provided)
Source: