Ameni Gaaloul
Ameni Gaaloul

Reputation: 43

How to $or with reactivemongo

How to create a query with reactiveMongo with the operator $or in order to find document by a field OR an other one. thanks in advance

Upvotes: 1

Views: 357

Answers (2)

Roman Kazanovskyi
Roman Kazanovskyi

Reputation: 3599

With BSON syntax:

BSONDocument("$or" -> BSONArray(
      BSONDocument("name" -> "JON"),
      BSONDocument("surname" -> "Tailor")
    ))

Upvotes: 1

Ameni Gaaloul
Ameni Gaaloul

Reputation: 43

this is the syntax

query = Json.obj(
  "$or" -> Json.arr(
    Json.obj("distributor.PhoneNb" -> phone),
    Json.obj("client.PhoneNb"->phone)
  )
)

Upvotes: 0

Related Questions