is this query a valid mongo jackson mapper query?

132 Views Asked by At

I'm trying to get a user by email or username from the database, imagine functionality that a user can login either with unique alias or email address, I thought the following would work but it doesn't,

User user  =  
coll.findOne(DBQuery.is("email", emailOrUsername).or(DBQuery.is("username", emailOrUsername)));

anything i'm missing?

1

There are 1 best solutions below

0
On BEST ANSWER

Ok, So apparently the way to create the above query is this:

coll.findOne(DBQuery.or(DBQuery.is("email", emailOrUsername),DBQuery.is("username",  emailOrUsername)));

I still don't know what the first query in the original question supposed to do.