> 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`
>
>