I have a collection that will, at times, have a subdocument where a key will be null. Something like:
{
_id: <some id>,
taskTimes: [{
startDateTime: <some ISO date time>,
endDateTime: <some ISO data time>
},
{
startDateTime: <some ISO date time>,
endDateTime: null
}],
client: "my client"
}
I’m trying to figure out how to update the subdocument to add the endDateTime where it’s currently null.
I tried a solution with $ifNull, but minimongo complains about it. Maybe I have it entered wrong.
return Tasks.update({ _id: taskId }, [{
$set: {
'taskTimes.endDateTime': {
$ifNull: {
endDateTime: endDateTime,
}
}
}
}]);
I get a web browser console error:
Uncaught MinimongoError: Key $ifNull must not start with '$'
at MinimongoError (common.js:1085:17)
at assertIsValidFieldName (local_collection.js:1922:11)
at Object.<anonymous> (local_collection.js:1913:7)
at JSON.stringify (<anonymous>)
at assertHasValidFieldNames (local_collection.js:1912:10)
at LocalCollection.insert (local_collection.js:102:5)
at Object.update (collection.js:239:28)
at store.<computed> [as update] (livedata_connection.js:312:38)
at livedata_connection.js:1340:19
at Array.forEach (<anonymous>)
As always, any help is greatly appreciated.