Heim >Datenbank >MySQL-Tutorial >MongoDB之DBref(关联插入,查询,删除) 实例深入

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

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

如图所示,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

  • Stellungnahme:
    Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn