I need to edit an item at a position(index) in an array without having to add an index to each item.
// The record in the collection
const data = {
library: 'The book store',
books: ['bookA', 'bookB', 'bookC']
}
I'm looking to only change the item at index 1 within the books array
I'm trying the following but it's not working...
return Record.updateOne(
{
video_id,
},
{
$set: {
"books[1]": 'Book H'
},
},
(err, data) => {
if (err) {
console.log(err);
}
return data;
}
);
Any ideas?