lundi 2 mars 2015

Randomly select a document in ArangoDB

Is there a way to randomly return a document from a collection using AQL?


I would like to create a random graph for testing purposes. I have not yet figured out how to select documents at random from the collection.


I was hoping I might be able to do something like this:



db._query('RETURN nodes[RAND(0..LENGTH(nodes))]').toArray()
JavaScript exception in file '/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js' at 104,11: [ArangoError 1541: invalid number of arguments for function 'RAND()', expected number of arguments: minimum: 0, maximum: 0 (while parsing)]
! throw new ArangoError(requestResult);


Any thoughts on how to do this?





Aucun commentaire:

Enregistrer un commentaire