有一個MongoDB集合,它是從角度資源返回的對象數組。將新對象插入特定數組索引
[{_id: "565ee3582b8981f015494cef", button: "", reference: "", text: "", title: "", …},
{_id: "565ee3582b8981f015494cf0", button: "", reference: "", text: "", title: "", …}]
我必須允許用戶插入一個對象到數組的任何索引,並通過Mongoose保存到MongoDB。
var object = {
button: "",
image: {},
reference: "",
text: "",
title: "",
};
我明白如何將對象推到數組的末尾,但我怎樣才能指定插入的索引?
到目前爲止,思維的第一創建對象:然後使用更新方法來更新陣列中的位置
Slide.create(object, function(result) {
console.log(result);
});
:
我需要更新此對象的MongoDB ......會澄清的問題。 TY –