Hi there,
It sounds like you're asking if MongoRecord supports polymorphism. If so, then yes, I believe it does. However, I typically use the MongoDocument implementation, so I don't have exact code for you. What I can tell you is that you'll need to define a type hints object for those classes and hook it into a formats object somewhere. TypeHints tell lift-json (the component that serializes your class) to include the class name in the serialized json when it's writing out to disk. So, somewhere you'd define the following...
// With your imports
import net.liftweb.json._
// With your model code
object Z {
val typeHints = FullTypeHints(List(
classOf[Z1],
classOf[Z2],
classOf[Z3]
))
}
Then, you just need to make sure that typeHints instance is attached to your serialization formats for the model. Using the MongoDocument structure, I'd do that by overriding the formats def in MongoDocumentMeta with my own implementation that included those type hints. For example...
override val formats = super.formats + Z.typeHints
In theory, you should be able to define a similar override somewhere in the MongoRecord setup.
I probably did a pretty miserable job of explaining this, so let me know if you have any additional questions.
Matt