When deploying a meteor app to a sandbox MongoDB that hasn't been updated to Mongo 3.0, I encounter limitations with the $position
and $each
queries.
Is there an alternative method to achieve the same result without using these queries?
I aim to prepend a task to the beginning of an array.
Below is the code snippet from the method:
newTask: function(task, date, number) {
if (! Meteor.userId()) {
throw new Meteor.Error("not-authorized");
}
if(number >= 0 && number <= 3){
let position = 'panels.' + number + '.tasks';
projectsDB.update({user: Meteor.user()._id}, {$push: {[position]: {name: task, date: date}}});
}
}
However, how can I replicate the following scenario
projectsDB.update({user: Meteor.user()._id}, {$push: {'panels.3.tasks': { $each: [{name: task, date: date}], $position: 0}}})
without relying on $position
and $each
?