Imagine having a MongoDB collection that consists of an array of objects being retrieved from an Angular Resource.
[{_id: "565ee3582b8981f015494cef", button: "", reference: "", text: "", title: "", …},
{_id: "565ee3582b8981f015494cf0", button: "", reference: "", text: "", title: "", …}]
The task at hand involves enabling the user to add an object to any specific index within the array and then saving it into MongoDB using Mongoose.
var object = {
button: "",
image: {},
reference: "",
text: "",
title: "",
};
I know how to add the object to the end of the array, but my question is: How can I determine the index for insertion?
My current approach involves initially creating the object:
Slide.create(object, function(result) {
console.log(result);
});
Then, I'm contemplating using an update method to specify the position in the array: