I was able to do an $addToSet
operation like this:
return Calls.update({ _id: callId }, {
$addToSet: {
units: {
unit: callSign,
currentStatus: "AS",
statusColor: "yellow",
textColor: "black",
assignable: false,
assignedBy: Meteor.users.findOne(this.userId).username,
assignedOn: new Date(),
},
}
}
);
But, when I try to update this collection like this:
return Calls.update({ _id: callId, "units.unit": callSign }, {
$set: {
"units.$.statusColor": "#74eeea",
"units.$.textColor": "black",
"units.$.currentStatus": "ER",
"units.$.enrouteBy": Meteor.users.findOne(this.userId).username,
"units.$.enrouteOn": new Date(),
}
}, {
upsert: true
}
);
I get this error:
Exception while invoking method 'call.enrouteUnit' MinimongoError: Key $ must not start with '$'
I know this is coming from the line (one if not all) in the $set
where I'm using the "<array>.$.<key>: <value>
format.
This has been working up till now, so not sure what's going on.
Update: The issue appears to be with my use of upsert
. Not sure why it suddenly decided that was an issue, but seems to be. Continuing to look at it.