简体   繁体   中英

Obtaining maximun _key value from an Arango Collection

Imagine that _key is a series which is always increasing, such as:

{
  _key:1,
  name: John,
  ...
},
{
  _key:2,
  name ...
},
...

I would like to get the maximum value of _key so I can include another element with a _key + 1 value.

I am using python-arango but I could collect the AQL query too.

To get the largest numerical _key value of collection coll so far:

      FOR c IN coll
        COLLECT AGGREGATE maxk = MAX(c._key)
        RETURN {max_coll_key: TO_NUMBER(maxk)}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM