Putting MAX() into the RETURN clause will make MAX() work on a scalar
value (the age), which will not work. This is because MAX() expects a
list as its argument.
It can be used like this:
RETURN MAX(users[*].age)
Of course this will enumerate all documents in the users collection and
put them into a temporary list. MAX() will then pick the maximum value
from the list.
If you can pre-filter the list of users it would be much better.
To return the "latest" document, I assume we can use the document with
the highest revision number in the collection.
This can generally be found with this query:
FOR u IN users SORT u._rev DESC LIMIT 1 RETURN u
However, this won't be efficient as it will enumerate all documents in
the collection, fetch their _rev value and sort by that.
There is currently no special construct to return just the "first" or
the "last" document from a collection.
I already thought about adding such functionality (for some different
purpose though) but there hasn't been time to do this yet.
Please feel free to submit a feature request so the issue won't vanish
from the radars.
Best regards
Jan
> --
> You received this message because you are subscribed to the Google
> Groups "ArangoDB" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
arangodb+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.