Open janm399 opened 11 years ago
+1
This would be best implemented as a DSL to create Spray JSON JsValue
instances, which are then serialised to DBObject. Also, side effect is: DSL for Spray JSON :-)
@janm399 ! Comment()
This could be awesome... your code can be entirely independent of ScalaD and it'll still work like a charm. i.e. if this
("username" equals username) &&
("expiryDate" lessThan now)
were converted into a JsObject
that looked like
{
"username": USERNAME,
"expiryDate": {"$lt": NOW}
}
where USERNAME and NOW are JsObject
s obtained from the relevant JsonFormat
. (USERNAME is trivial here, but NOW will be our custom Date type that is auto-converted into a MongoDB DateFormat by the serialised)
and also, if we're wanting to do things like findModify it is a simple case of extending the CRUD traits to take in more DBObject
s that we'll implicitly convert from the DSL :-)
I know I'm not working on the project, but I couldn't resist to chime in :D
I like Sam's idea, I think could be the more scalaDble (pun intended) approach:
If you guys work on a DSL / Implicit system to convert that kind of expression to valid JsObject
you will have free queries, because if things aren't changed I remember you can pass a JsObject
to do queries, and so you are in business :P
@adinapoli You're more than welcome to chip in any time; I'd love to have contributions and ideas. I'll sketch out my DSL this AM.
@janm399 sweeet - is it a Spray JSON builder?
Implement implicit conversions to
DBObject
using some convenient DSL so that you can use it nicely in theMongoSearch.searchAll
and others.The ideal implementation will allow you to write something like