Re: Demo project has been created, now I have a problem of `a question embeds some comments`

5 views
Skip to first unread message
Message has been deleted

Alexander Azarov

unread,
Mar 21, 2011, 1:50:49 PM3/21/11
to mongod...@googlegroups.com

20.03.2011 at 17:27, Freewind wrote:

> I just create a demo:
>
> https://github.com/freewind/mongo-scala-demo
>
> I have resolve `a user refs some questions`, but now I have a new
> problem:
>
> How to implement "a question embeds some comments"?
>
> I hope the question collection has such structure:
>
> questions {
> title = xxxx
> comments {
> { _id = 'objectid1', content='xxxxx', question_ref =
> "xxx" },
> { _id = 'objectid2', content='xxxxx', question_ref =
> "xxx" },
> }
> }
>
> I hope the comment have a "_id" because I can delete a comment easily.

MongoDB embedded documents do not have _id field, only top-level docs have.


> But in my tests, I found the comments saved in mongodb not have a
> "_id" and "question" ref.
>
> See:
>
> https://github.com/freewind/mongo-scala-demo/blob/master/src/test/scala/question_tests.scala
>
> You can clone it via git, and use sbt to run the tests. The dbname I
> used in tests is `smongodb`
>
>

Reply all
Reply to author
Forward
0 new messages