简体   繁体   English

在ArangoDB查询中绑定列表值

[英]Bind list value in ArangoDB query

I'm facing some issues when trying to bind a list variable in an ArangoDB query. 尝试在ArangoDB查询中绑定列表变量时,我遇到了一些问题。 More concretely, the list might look like as follows and comes from a URL parameter in a certain Foxx controller endpoint: 更具体地说,列表可能如下所示,来自某个Foxx控制器端点中的URL参数:

.../someAPIEndpoint?list=A,B,C,D

I would like to be able to do something like this: 我希望能够做到这样的事情:

stmt = db._createStatement({query: "for i in [@list] return i"});
stmt.bind('list', req.params('list').split(','));

Since I do not know how many values will I receive from the API call, I can't create n bindings for each possible one. 由于我不知道API调用会收到多少值,因此无法为每个可能的值创建n个绑定。 Is what I want to achieve even possible? 我想实现甚至可能吗?

Thanks in advance. 提前致谢。

you were almost there, you can bind an array directly to the parameter (i just removed "[" and "]" from your query: 你几乎就在那里,你可以直接将数组绑定到参数(我刚刚从你的查询中删除了“[”和“]”:

stmt = db._createStatement({query: "for i in @list return i"});
stmt.bind('list', req.params('list').split(','));

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

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