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

2014-11-24 18:23:17 · 作者: · 浏览: 0

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



我们先建立A collection。



所以:



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




查询




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

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.