scala - Map MongoDB _id using Play-Reactivemongo plugin? -
i'm trying utilize play-reactivemongo plugin read/write simple records in mongodb play , angular. plugin seems nice alternative allows utilize simple case classes , regular json instead of explicitly converting between bson , json. few examples of using plugin don't seem cover how map mongodb object id to/from json within same framework. seems work load of implicit (= magic me) reads/writes in background, don't seem handle object id.
my code based on alex lashford's modern web template, , similar stephan godbillion's illustration using json read/writes, neither alex nor stephan shows mongodb object id.
i need kind of unique id info records, can fetch , update them etc, , makes sense utilize 1 mongodb provides, can't seem find way utilize cleanly within play reactivemongo plugin.
does know of illustration shows how utilize play reactivemongo plugin json collections , way map object id to/from json without having convert processing utilize bson?
i've solved issue creating case class:
case class id($oid: string) then utilize follows:
case class user(_id: id, ...) you have have json converters imported
implicit val idformat = json.format[id] implicit val userformat = json.format[user] mongodb scala playframework play-reactivemongo
No comments:
Post a Comment