2

I have an eve app running on my mongodb collection col10. I am trying to get a response where I have multiple values selected from the same key, example:

http://127.0.0.1:4567/col10?where={"var0053":[1130,1113]}
## returns 0 objects

I have also tried:

http://127.0.0.1:4567/col10?where=var0053==[1130,1113] 
## returns just the objects with var0053 = 1113

is there a way of requesting to server more than one value from the same key?

motipai
  • 328
  • 3
  • 10

2 Answers2

1

If you are using GET method your url should be looking like that :

 http://IP_ADDRESS:8080/test?list=1&list=2&list=3

for retrieving it:

String[] arrlist=request.getParameterValues('list');

your array will be filled with separated values:

//["1","2","3"]

When you retrieving your list parameters it wouldn't be parsed as array but as a series of String which will be grouped later on into an array. Which means even if you write it list[]=1&list[]=2&list[]=3, list[=1&list[=2&list[=3, list*=1&list*=2&list*=3 or list=1&list=2&list=3 it would always be giving you the same answer whether you retrieve it as

request.getParameterValues('list[]') //["1","2","3"]
request.getParameterValues('list[') //["1","2","3"]
request.getParameterValues('list*') //["1","2","3"]
request.getParameterValues('list')  //["1","2","3"]
Dmitrii Sidenko
  • 660
  • 6
  • 19
1

With Eve, you can use mongodb syntax for queries, like this:

http://127.0.0.1:4567/col10?where={"var0053": {"$in": ["1130", "1113"]}}

Documentation is here https://docs.python-eve.org/en/stable/features.html#filtering.

gcw
  • 1,639
  • 1
  • 18
  • 37