There is a MongoDB collection, which is an array of objects being returned from an Angular Resource.
[{_id: "565ee3582b8981f015494cef", button: "", reference: "", text: "", title: "", …},
{_id: "565ee3582b8981f015494cf0", button: "", reference: "", text: "", title: "", …}]
I have to allow the user to insert an object into any index of the array, and save to MongoDB through Mongoose.
var object = {
button: "",
image: {},
reference: "",
text: "",
title: "",
};
I understand how to push the object to the end of the array, but how can I specify what index for the insertion?
So far, thinking of first creating the object:
Slide.create(object, function(result) {
console.log(result);
});
Then using an update method to update the position in the array: