Property
Extractor for BSON property, allowing partial and un-ordered match by name.
import reactivemongo.api.bson.BSONString
import acolyte.reactivemongo.{
PreparedResponse, Property, Request, SimpleBody
}
val EmailXtr = Property("email") // Without scalac plugin
def resultA: PreparedResponse = ???
def resultB: PreparedResponse = ???
def resultC: PreparedResponse = ???
def resultD: PreparedResponse = ???
def resultE: PreparedResponse = ???
def check(request: Request) = request match {
case Request("db.col", SimpleBody(EmailXtr(BSONString(e)))) =>
// Request on db.col with an "email" string property,
// anywhere in properties (possibly with others which are ignored there),
// with `e` bound to extracted string value.
println(e)
resultB // similar to case resultA without scalac plugin
case req =>
sys.error("Unexpected request: " + req)
}
- See also:
&