Hi there,
I’m trying to resolve what part of functionality of updating nested arrays is working in Mongo.Collection just like in native MongoDB driver.
Is it possible to write that code using normal FlashcardCollection.update()
?.
Meteor.methods({
'flashcard.edit': async (id, {front, back}) => {
FlashcardCollection.rawCollection().updateMany({}, {
$set: {
"flashcards.$[element].front": front,
"flashcards.$[element].back": back
}
}, {
arrayFilters: [
{
"element._id": id
}
]
})
}
});
I get errors from SimpleSchema which are telling me that i’m trying to edit field flashcards.$[element].front
so I assume that it’s not parsing the field correctly. On the other hand, above code works correctly.
I was reading Collections | Meteor API Docs and docs say that arrayFilter with filtered positional operator is present on Mongo.Collection class.
I would be glad for help.