Document store the data in the form of JSON objects. Every document has a key and handle.
Document key
Document key is a string used to uniquely identify a document within the collection. Document key is stored in _key attribute of the document. Once _key attribute is assigned with a value, it is immutable, its value is not going to be changed any time.
Is the document key values are indexed?
Yes
Can I provide custom value to _key attribute?
Yes, you can. But you need to make sure that the _key value is unique in the collection and it is immutable.
Document Handle
Document handle is used to uniquely identify a document within the database. It is a string consist of collection name followed by / followed by the value of _key attribute.
Example
127.0.0.1:8529@abc_org> userCollection.save({"id" : 1, "firstName": "Ram"}) { "_id" : "user/12977", "_key" : "12977", "_rev" : "_cRdSijO---" }
In the above example, 12977 is the Document key and "user/12977" is the document handle.
Document Revision
Every document has a revision specified using _rev attribute. _rev attribute is read-only to the user. It is calculated by ArangoDB server. Whenever a document is updated, this revision value is going to be changed.
For example, lets create a document.
127.0.0.1:8529@abc_org> userCollection.save({"lastName" : "Gurram", "firstName": "Ram"}) { "_id" : "user/14434", "_key" : "14434", "_rev" : "_cRd20V6---" }
Let’s update the document and confirm that the revision is updated.
127.0.0.1:8529@abc_org> userCollection.update("user/14434", {"lastName": "Battu"}, false, false) { "_id" : "user/14434", "_key" : "14434", "_rev" : "_cRd4ppe---", "_oldRev" : "_cRd20V6---" }
You can observe that new revision is updated. After some time old revision content is deleted.
Can I perform operations on multiple documents using single command?
Yes, from ArangoDB 3.0 onwards, you can perform actions on multiple documents in a single command.
No comments:
Post a Comment