Tuesday, 14 September 2021

ArangoDB: AQL: Read multiple documents by ids or keys

Syntax

RETURN DOCUMENT(collection_name, array_of_doc_ids_or_keys)

 

Example

RETURN DOCUMENT("users", ["41308", "users/41688"])

 

Above snippet return below documents.

[
  [
    {
      "_key": "41308",
      "_id": "users/41308",
      "_rev": "_cSAxcHm---",
      "id": 1,
      "firstName": "Krishna",
      "lastName": "Gurram"
    },
    {
      "_key": "41688",
      "_id": "users/41688",
      "_rev": "_cSA6tje--A",
      "id": 3,
      "firstName": "Madhu",
      "lastName": "Thatha"
    }
  ]
]

You can execute the same query using arangosh or webui.

127.0.0.1:8529@abc_org> db._query(`RETURN DOCUMENT("users", ["41308", "users/41688"])`)
[object ArangoQueryCursor, count: 1, cached: false, hasMore: false]

[ 
  [ 
    { 
      "_key" : "41308", 
      "_id" : "users/41308", 
      "_rev" : "_cSAxcHm---", 
      "id" : 1, 
      "firstName" : "Krishna", 
      "lastName" : "Gurram" 
    }, 
    { 
      "_key" : "41688", 
      "_id" : "users/41688", 
      "_rev" : "_cSA6tje--A", 
      "id" : 3, 
      "firstName" : "Madhu", 
      "lastName" : "Thatha" 
    } 
  ] 
]


 

Previous                                                    Next                                                    Home

No comments:

Post a Comment