Greetings to all
I am using the following example from the wiki:
Record Referenced Objects
https://www.assembla.com/spaces/liftweb/wiki/Mongo_Record_Referenced_Objects
but with the following changes:
class Posts private() extends MongoRecord[Posts] with
ObjectIdPk[Posts] {
def meta = MainDoc
object name extends StringField(this, 12)
object userId extends ObjectIdRefField(this, User) {
override def options = User.findAll.map(user => (Full(
user.id.is),
user.nickname.is))
}
}
object Posts extends Posts with MongoMetaRecord[Posts]
class User private() extends MongoRecord[User] with ObjectIdPk[User] {
def meta = RefDoc
object nickname extends StringField(this, 12)
}
object User extends User with MongoMetaRecord[User]
and I want to make a query to get the following:
<span id="rows">
<p id="name">My post</p>
<p id="nickname">My nickname</p>
</span>
and the query that I'm trying to do is this:
val post = Posts.findAll()
"#rows" #> post.map { p =>
"#name" #>
p.name &
"#username" #>
p.userId.obj.user.nickname.is)
}
I know something is wrong with the following line:
"#username" #>
p.userId.obj.user.nickname.is)
My question is this:
anyone can help me and please tell me what I'm missing or what I'm
doing wrong
I have no experience with Mondodb and am trying to understand how to
use the references
Thanks for your attention