I have an object type representing a threaded comment that I want to
organize into trees - what's the best way to represent this
relationship with Mapper? My naive idea is to do something like:
class Comment extends LongKeyedMapper[Comment] with IdPK {
...
object parentComment extends MappedLongForeignKey(this, Comment) {
override def dbColumnName = "parent_comment_id"
override def defaultValue = -1
}
...
def getParentComment():Box[Comment] = {
if(this.parentComment.is == -1) {
Empty
}
else {
Comment.find(By(Comment.id, this.parentComment))
}
}
}
Is there a way to do this more directly so that Comment.parentComment
just gives me something I can feed into type matching rather tahn
doing the explicit check against -1 in a wrapper funciton?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---