1
我有一個MongoDB數據庫,我試圖用連接字符串替換特定元素的所有數組。目前,大多數文檔都有一串字符串。我需要一個腳本來查找每個包含數組的文檔(有些已經手動更新),然後將該數組替換爲當前內容的串聯。在MongoDB中替換類型
到目前爲止,我有:
var cursor = db.recipe.find({ directions: { $type : 4 } });
while (cursor.hasNext()) {
var doc = cursor.next();
db.recipe.update(
{ _id : doc._id },
{ $set : { directions : { $concat : { doc.directions } } } }
);
};
不幸的是,它不斷抱怨意外 ''。我假設我正確使用$ concat。