简体   繁体   English

在 Arangodb 的数组中时如何过滤集合中的文档?

[英]How to filter documents in a collection when inside an array in Arangodb?

I am going through the tutorial on Arangodb which is using a sample game of thrones dataset.我正在 阅读关于 Arangodb 的教程,该教程使用了一个宝座数据集示例游戏。 I am trying to figure out how I would be able to filter out characters based on a trait?我想弄清楚如何根据特征过滤掉字符?

 INSERT {
    "name": "Ned",
    "surname": "Stark",
    "alive": true,
    "age": 41,
    "traits": ["A","H","C","N","P"]
} INTO Characters

I am trying to use the following code but its not working.我正在尝试使用以下代码,但它不起作用。 Would the above traits be an array.上述特征会是一个数组吗? if so how do I proceed?如果是这样,我该如何进行?

for c in Characters
Filter c.traits =="A"
RETURN c

Thank you!谢谢!

If you want to find all characters that have trait "A" you can use FILTER "A" IN c.traits , ie, the characters may also have other traits.如果要查找所有具有特征“A”的字符,可以使用FILTER "A" IN c.traits ,即,这些字符可能还具有其他特征。 If you want to find characters that have only trait "A" you can use FILTER c.trait == ["A"] .如果你想找到只有特征“A”的字符,你可以使用FILTER c.trait == ["A"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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