it:ad:arangodb:howto:api:js:documents_retrieve

IT:ArangoDB:HowTo:API/JS/Documents/Retrieve

Querying data is so powerful that we'll skip it for now, and come back to it in a second.

//retrieve document using it's handle:
db.demo.document("demo/362549736")

//equivalent shortcut is to drop the collection name:
db._document("demo/362549736")

AQL is ArangoDB's proprietary syntax similar to SQL.

Reference:


JSH> db._query('FOR x IN example FILTER x.Hello == "World" return x').toArray(); 
==> [ { "_id" : "example/34951485", "_rev" : "34951485", "_key" : "34951485", "Hello" : "World" } ]

You can also project the results (equivalent of Linq's SELECT statement):

JSH> db._query('FOR x IN example FILTER x.Hello == "World" return x.Hello').toArray(); 

==> [  "World" ]

A newbie gotcha is not noticing that the _query method belongs to db – not the collection in the db.

…or that it starts with an underscore.

The _query command, btw, is a shortcut for _createStatement and execute.

  • /home/skysigal/public_html/data/pages/it/ad/arangodb/howto/api/js/documents_retrieve.txt
  • Last modified: 2023/11/04 02:42
  • by 127.0.0.1