Is there a way to dynamically build up a QueryCondition?
IsaacJimenez17 opened this issue · 2 comments
Let's say this is in the context of an API endpoint. The client may include a number of different query params in their request. Given that I don't know what params may or may not be provided, I can't really write a one size fits all query where I simply fill in values for all of the condition.
Rather, I would like to do something akin to initializing an empty QueryCondition, and then dynamically adding to it as I iterate over the provided query params.
queryCondition = QueryCondition()
if paramA is not None:
queryCondition = queryCondition.and_(Item.paramA.equals("001")
if paramB is not None:
queryCondition = queryCondition.and_(Item.paramB.equals("Foo")
// So on and so forth for n number of query params
query = objectbox._item_box.query(queryCondition).build()
result = query.find()
Is something like this possible? Perhaps it is, and I'm simply going about it all wrong. With the example I gave above, I'm getting a NotImplementedError from line 27 of condition.py
Thanks for reporting! I'm not familiar with Python, but looking at the Queries docs, conditions are combined using the &
and |
operators. Does using them work?
Closing this issue due to inactivity. 💤 Feel free to comment with more details or submit a new issue.