如果字段不存在则更新文档

时间:2015-08-10 11:43:28

标签: mongodb

我在mongodb中有两个集合:ColAColB

colA

    "_id" : "89479574905"
    "NETWORK" : "AAA",
    "BUSINESS_ID" : "148013"

colB

 "_id" : "78787878"
"NETWORK" : "BBB",
"BUSINESS_ID" : "148456",
"BUSINESS_NAME" : "Hello",
"BUSINESS_URL" : "www.some.net",
"LOCATION" : "Delhi"

我想更新colA,以便结果应为:

"_id" : "89479574905"
"NETWORK" : "AAA",
"BUSINESS_ID" : "148013",
"BUSINESS_NAME" : "Hello",
"BUSINESS_URL" : "www.some.net",
"LOCATION" : "Delhi"

如果colA中出现相同的字段,则不要仅更新插入其他字段。

你会怎么做?

0 个答案:

没有答案