I am using Python-Eve REST API
and I want to read using POST
. I want to use OR
condition in my query payload like :
{"id":1 or "id":2}.
So that I will get all response with id = 1
or those with id = 2
.
I am using SQLALCHEMY as my database.
Simply use list as a value of that key, it makes easy for you with python lists.
payload = { "id": [1, 2] ... }
If the case if that any of the 'id' is zero or NoneType, you can use this condition.
variable_1 = None
variable_1 = 3
payload = {
"id": variable_1 or variable2
}
#payload becomes like this
payload = {
"id": 3
}
您可以在get请求的where子句中使用$ in:
?where={"id":{"$in":["1", "2"]}}
Assuming you are using a Mongo Backend, look at the Mongo Query documentation
You can try a GET request to query values
http://app/values?where={ id: { $in: [1, 2] } }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.