热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

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

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

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

    推荐阅读
    author-avatar
    jing阿囡宝_478
    这个家伙很懒,什么也没留下!
    PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
    Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有