When working with document-based databases such as MongoDB, instead of using a one-to-many relationship to link to classes that represent two tables in the database—such as
phones—we can map both objects
Phone. Then, instead of storing them in two different collections, we embed the
phone object into the
contact object. In the following recipe, we will learn how to embed one object into another.
We'll keep evolving the project from the previous recipe.
Carry out the following steps:
src/main/scala/code/modelwith the following code:
package code.model import net.liftweb.mongodb.record._ import net.liftweb.record.field.StringField class ...