How to count number of elements with AQL?

自古美人都是妖i 提交于 2019-12-24 01:46:21

问题


I need to count elements that was in result of SQL query: db._query('FOR v in visitors FILTER v.ip == "127.0.0.1" return COUNT(v.guid) ')

This request is return my a length of every GUID, but I need to get total number of GUIDs for example: 2.


回答1:


You need to use the result of the query as input for the COUNT function, and then RETURN this result.

You can replace the RETURN value of the actual query by 1 for performance reasons:

RETURN COUNT(FOR v IN visitors FILTER v.ip == "127.0.0.1" RETURN 1)


来源:https://stackoverflow.com/questions/37077048/how-to-count-number-of-elements-with-aql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!