3
votes

I'm facing some issues when trying to bind a list variable in an ArangoDB query. More concretely, the list might look like as follows and comes from a URL parameter in a certain Foxx controller endpoint:

.../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. Is what I want to achieve even possible?

Thanks in advance.

1

1 Answers

2
votes

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(','));