Add converting to BSONDocument
It would be great if there would be a way to convert json to BSONDocument (reactivemongo) and there would be a way to create custom handlers for some fields.
Hi, @andemi !
Two questions:
- You need exactly
BSONDocument, orByteBufferwith BSON will be OK too? - What do you mean when talking about "custom handlers for some fields"? This -
case class User(@key("user_name") userName: String)?
I think I hurried. After JSON we need validate data, so direct converting JSON to BSONDocument is redundant.
- BSONDocument http://reactivemongo.org/releases/0.11/api/index.html#reactivemongo.bson.BSONDocument
- No, validation or changing some data
What means "validate"? It's needed for be sure thats email is email and age not 999? If it is, I suppose we can do it before converting to BSON. Anyway pushka.Ast to BSONDocument conversion will be lose data type precision: DateTime and Timestam became just Longs.
I have old plans about supporting various AST #3. It's next big thing in Pushka, so I planing to take this issue to work in few next months. I can take reactive-mongo as first external AST backend if you help me to realize requirements of reactive-mongo.
It's needed for be sure thats email is email and age not 999? Yes, something like this.
Here some data types classes http://reactivemongo.org/releases/0.11/documentation/bson/typeclasses.html and http://reactivemongo.org/releases/0.11/documentation/json/overview.html
So what "validation" means?
For example, all data that comes from frontend must be checked
Ok. "Yes, something like this" is in quote :) Such kind of validation is not Pushka's job. You can validate fields after case class was read.
Waiting for #3.