I have a basic model with a case class
case class Record( id: Option[String],
data: Double,
user: String,
)
object RecordJsonFormats {
import play.api.libs.json.Json
implicit val recordFormat = Json.format[Record]
}
Field user is actually an ObjectId of other module also id is also an ObjectId yet then try to change String type to BSONObjectId macros in play.api.libs.json.Json break... so both user and if saved with object id fields get saved as String not ObjectId.
What is the optimal way to operate with ObjectIds in Play framework?
- Maybe I should extend
play.api.libs.json.JsonwithBSONObjectId? - Maybe there is a way to link models and IDs are tracked automatically without a need to declare them in model?