IT:ArangoDB:HowTo:API/JS/Documents/Retrieve
Summary
The JS client to the ArangoDB server's RESTful API provides several methods to retrieve data.
Process
Querying data is so powerful that we'll skip it for now, and come back to it in a second.
Using a document handle
//retrieve document using it's handle:
db.demo.document("demo/362549736")
//equivalent shortcut is to drop the collection name:
db._document("demo/362549736")
Using AQL
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.