3.2 KiB
Handling Documents
@NAVIGATE_ShellDocument @EMBEDTOC{ShellDocumentTOC}
This is an introduction to ArangoDB's interface for documents and how handle documents from the JavaScript shell arangosh. For other languages see the corresponding language API.
Documents, Identifiers, Handles
@copydoc GlossaryDocument
For example:
{
"_id" : "demo/2345678",
"_rev" : "3456789",
"_key" : "2345678",
"firstName" : "Hugo",
"lastName" : "Schlonz",
"address" : {
"street" : "Strasse 1",
"city" : "Hier"
},
"hobbies" : [
"swimming",
"biking",
"programming"
]
}
All documents contain special attributes: the document handle in _id
, the
document's unique key in _key
and and the etag aka document revision in
_rev
. The value of the _key
attribute can be specified by the user when
creating a document. _id
and _key
values are immutable once the document
has been created. The _rev
value is maintained by ArangoDB autonomously.
@copydoc GlossaryDocumentHandle
@copydoc GlossaryDocumentRevision
@copydoc GlossaryDocumentEtag
Address and ETag of an Document
All documents in ArangoDB have a document handle. This handle uniquely defines a document and is managed by ArangoDB. The interface allows you to access the documents of a collection as:
db.@FA{collection}.documet(@FA{document-handle})
For example: Assume that the document handle, which is stored in the _id
field
of the document, is demo/362549
and the document lives in a collection
named @FA{demo}, then that document can be accessed as:
db.demo.document("demo/362549736")
Because the document handle is unique within the database, you can leave out the @FA{collection} and use the shortcut:
db._document("demo/362549736")
Each document also has a document revision or etag with is returned in the
_rev
field when requesting a document. The document's key is returned in the
_key
attribute.
@CLEARPAGE Working with Documents
Collection Methods
@anchor ShellDocumentRead @copydetails JS_DocumentVocbaseCol
@anchor ShellDocumentAny @copydetails JS_AnyQuery
@CLEARPAGE @anchor ShellDocumentCreate @copydetails JS_SaveVocbaseCol
@CLEARPAGE @anchor ShellDocumentReplace @copydetails JS_ReplaceVocbaseCol
@CLEARPAGE @anchor ShellDocumentUpdate @copydetails JS_UpdateVocbaseCol
@CLEARPAGE @anchor ShellDocumentRemove @copydetails JS_RemoveVocbaseCol
@CLEARPAGE @anchor ShellDocumentRemoveByExample @copydetails JSF_ArangoCollection_prototype_removeByExample
@CLEARPAGE Database Methods
@anchor ShellDocumentDbRead @copydetails JS_DocumentVocbase
@CLEARPAGE @anchor ShellDocumentDbReplace @copydetails JS_ReplaceVocbase
@CLEARPAGE @anchor ShellDocumentDbUpdate @copydetails JS_UpdateVocbase
@CLEARPAGE @anchor ShellDocumentDbRemove @copydetails JS_RemoveVocbase