Home >Database >Mysql Tutorial >MongoDB之DBref(关联插入,查询,删除) 实例深入

MongoDB之DBref(关联插入,查询,删除) 实例深入

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:03:561369browse

如图所示,A,B,C三个Collection互相关联。 其中的数字为document的value值。

如图所示,,A,B,C三个Collection互相关联。 其中的数字为document的value值。

关于DBref的入门可以看 这篇文章。

我们先建立A collection。

B collection以A collection的  _id为ObjectId("4e3f33de6266b5845052c02c")作为Apid

所以:

C collection以B collection的  _id为 ObjectId("4e3f3de16266b5845052c036") 作为Apid

目前为止3个collection 的关系已经建成。

查询

 

  • 其实好好想想引用不是必须的。

    MongoDB 权威指南说了这么一句:

    In short,the best time to use DBRefs are when you're storing heterogeneous references to documents in different collections.like when you want to take advantage of some additional DBRef-specific functionality in a driver or tool.

    linux

  • Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn