使用节点js进行MongoDB手册和DBRef引用

时间:2017-06-07 11:35:27

标签: node.js mongodb mongodb-query

我有两种情况,第一种情况:在我的密钥中引用同一个集合的地方,这是正确的引用方式吗?,如果是的话!如何在节点js中取消引用/链接?如果不是如何引用同一个集合

{
"_id" : ObjectId("53402597d852426020000002"),
"address" : {
    "$ref" : "home_adress"
},
"contact" : "987654321",
"dob" : "01-01-1991",
"name" : "Tom Benzamin",
"Post_address" : {
    "$ref" : "home_adress"
},   
"home_adress":"Street 1, NY"} 

案例二:引用不同的集合(DBRefs),如何检测引用并发送第二个查询以获取引用的值?

{
"_id" : ObjectId("53402597d852426020000002"),
"address" : {
    "$ref" : "address_home",
    "$id" : ObjectId("534009e4d852427820000002"),
    "$db" : "ref"
},
"contact" : "987654321",
"dob" : "01-01-1991",
"name" : "Tom Benzamin"}


{
"_id" : ObjectId("534009e4d852427820000002"),
"building" : "22 A, Indiana Apt",
"pincode" : 123456,
"city" : "Los Angeles",
"state" : "California"}

0 个答案:

没有答案