Monday 20 September 2021

ArangoDB: AQL: Skip and return next n documents

Syntax

FOR doc IN colleciton
    LIMIT K, N
    RETURN doc

 

Above snippet skip first k documents and return next N documents.

 

Example

queryToExecute = `FOR doc IN users
    LIMIT 2, 3
    RETURN doc`
127.0.0.1:8529@abc_org> queryToExecute = `FOR doc IN users
...>     LIMIT 2, 3
...>     RETURN doc`
FOR doc IN users
    LIMIT 2, 3
    RETURN doc

127.0.0.1:8529@abc_org> db._query(queryToExecute)
[object ArangoQueryCursor, count: 3, cached: false, hasMore: false]

[ 
  { 
    "_key" : "43460", 
    "_id" : "users/43460", 
    "_rev" : "_cSBlsQe---", 
    "firstName" : "Ram", 
    "lastName" : "Gurram", 
    "age" : 35 
  }, 
  { 
    "_key" : "43468", 
    "_id" : "users/43468", 
    "_rev" : "_cSBl3BW---", 
    "firstName" : "Siva", 
    "lastName" : "Ponnam", 
    "age" : 35 
  }, 
  { 
    "_key" : "43482", 
    "_id" : "users/43482", 
    "_rev" : "_cSBmJqO---", 
    "firstName" : "Joel", 
    "lastName" : "Chelli", 
    "age" : 34 
  } 
]

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment