mongo-jackson-mapper

is this query a valid mongo jackson mapper query?


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?


Solution

  • 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.