0
移动项目我有这样MongoDB中添加属性,并从其他
{
name : "test"
data : [{"itemcode":"a1"},{"itemcode":"a2"}]
}
我需要改变,以
{
name : "test"
shops :[
{ "shopid" : 1,
"data" : [{"itemcode":"a1"},{"itemcode":"a2"}]
}]
}
我尝试更新的对象,但我不能复制的阵列仍然ramain空。更新我使用
db.getCollection("shop").find({}).forEach(function(doc){
var a = doc.data;
var s = [{
"shopid":NumberInt(1),
"data": a}]
db.collection.save(doc);
});