Reputation: 37
I want to write a validation check where the query should return all users with a given username "OR" a given email. How could I write such a query using the mongo_dart package without having to query all the data and check it manually?
example query: if username=="x" or email=="y"
The tried this using the below query, but it did not work.
List<dynamic> all = await coll2.find({
"or": [
{"username": username},
{"email": email}
]
}).toList();
Moreover, using $or
instead of or
is raising syntax error in dart.
Upvotes: 0
Views: 42
Reputation: 8316
You can try:
await coll2.find(
where.eq('username', username).or(where.eq('email', email))
).toList();
Upvotes: 0