mongodbscalasalat

How to read and write from MongoDb using two different drivers (MongoDB Scala Driver and Salat)


We want to change our MongoDB driver overtime to MongoDB Scala Driver, but we using Salat and it reads and writes sealed classes and ADTs using "_typeHint" to the DB. The MongoDB Scala Driver reads and writes sealed classes and ADTs using "_t", What we want is a way to read and write "_typeHint" using MongoDB Scala Driver? We know we need a custom codec, but not sure how to implement it.

We want the ability to support both drivers until we remove Salat.

Thanks.


Solution

  • This appears to be described here. See "annotation convention" and "bson discriminator".