Operations on DocumentDB Documents
The DocumentDB API supports basic CRUD operations on the resources under a database account. This topic outlines the REST operations used to manage DocumentDB documents.
The document resource is represented by docs in the DocumentDB resource model. A document consists of user-defined content in JSON format. Aside from the required id property, users can define any arbitrary elements, structures, and hierarchies for the content. The id element is a unique string that is user-settable and must not exceed 255 characters.
By default, documents are automatically indexed, thus making a document queryable as soon as it is created.
Attachments can also be linked to a document. For more information on attachments, see Operations on Attachments.
As illustrated in Operations on Permissions, user access to documents can be managed via the permissions resource under users.
This sample JSON document shows a catalog entry for a travel book. The entry includes the id element, which is set to the ISBN identifier, the user defined elements, and the system defined elements.The following example shows an example of a JSON document created within DocumentDB:
{
"id":"ISBN 0-8800-1599-1",
"Title":"About Kansas City",
"Language":{
"id":"English"
},
"Author":{
"id":"James",
"Location":{
"City":"Kansas City",
"Country":"United States"
}
},
"Content":"Kansas City, one of the top BBQ cities in the U.S.....",
"PageViews":400,
"Topics":[
{
"Title":"History of Kansas City"
},
{
"Title":"Places to see in Kansas City"
}
],
"_rid":"9VNiAL+V2AAEAAAAAAAAAA==",
"_ts":1408328515,
"
_self":"dbs\/9VNiAA==\/colls\/9VNiAL+V2AA=\/docs\/9VNiAL+V2AAEAAAAAAAAAA==\/",
"_etag":"00003b00-0000-0000-0000-53f163430000",
"_attachments":"attachments\/"
}
Property |
Description |
id |
Required. This is a user settable property. It is the unique name that identifies the document, i.e. no two documents will share the same id within a database. The id must not exceed 255 characters. |
_rid |
This is a system generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the document resource. |
_ts |
This is a system generated property. It specifies the last updated timestamp of the resource. The value is a timestamp. |
_self |
This is a system generated property. It is the unique addressable URI for the resource. |
_etag |
This is a system generated property that specifies the resource etag required for optimistic concurrency control. |
_attachments |
This is a system generated property that specifies the addressable path for the attachments resource. |
The allowable operations on the document resource are as follows:
See Also
Azure DocumentDB REST API Reference
Access Control on DocumentDB Resources
Querying DocumentDB Resources
HTTP Status Codes for DocumentDB
Operations on DocumentDB Databases
Operations on DocumentDB Users
Operations on DocumentDB Permissions
Operations on DocumentDB Attachments
Operations on DocumentDB Document Collections
Operations on Stored Procedures
Operations on User Defined Functions
Operations on Triggers