Is there a way to do an `OR` between two subquerie...
# realm
g
Is there a way to do an
OR
between two subqueries? I have a big query with subqueries build like this:
Copy code
var query = query<Model>("id == $0", id)
        if (otherModelId != null) {
            query = query.query("otherModel.id == $0", otherModelId)
        }
        if (markedOnly) {
            query = query("flagged == $0", true)
        }
And now I need to add OR to the top level query.
c
We don’t have an API for OR-ing two RealmQuery objects right now, but you can use
query.description()
to create a new one, something like:
Copy code
var query = query<Model>("id == $0", id)
        if (otherModelId != null) {
            query = query.query("otherModel.id == $0 OR ${query.description()}", otherModelId)
        }
        if (markedOnly) {
            query = query("flagged == $0 OR ${query.description()}", true)
        }
(Not sure if that was the queries you wanted to OR, but hopefully you get the the idea)
g
nice thanks, I can work with that 👍
👍 1