ReactiveMongo with Play 2.3

266 views Asked by At

I'm working on Play 2.3 with ReactiveMongo. I want to query the db which should search by a id and a name or a mobile number. which ever matches among the name and mobile number.

The query in the db level which worked is as follows.

 db.endUser.find({$and:[{businessUserId:"1"},{ $or: [{name:"Ruthvick"},{mobileNumber:"989"}]}]})

but the same to write as per play syntax is not fetching any result. The query in scala which didn't work is as follows.

val cursor: Cursor[JsObject] = collectionEndUser.find(
        Json.obj("$and"->Json.arr(Json.obj("businessUserId"->"",
         "$or"->Json.arr(Json.obj("name"->"Ruthvick",
         "mobileNumber"->"9686563240")))))
              ).cursor[JsObject]

Kindly review the query and help me with necessary changes.

Thanks

0

There are 0 answers