I’m trying to insert documents into an array while also updating fields of existing elements in the same array. Am I doing something wrong, or is this not possible in a single operation?
I’m seeing this error: Updating the path 'userJourneyEvents.$[event].touchpoints' would create a conflict at 'userJourneyEvents.$[event].touchpoints'
I’m using the NodeJS driver, calling findOneAndUpdate
with the following parameters:
query {
userJourneyEvents: {
'$elemMatch': { id: 'eid' }
}
}
eventUpdate {
'$set': {
'userJourneyEvents.$[event].touchpoints.$[touchpoint0].description': 'description'
},
'$push': {
'userJourneyEvents.$[event].touchpoints': {
'$each': [
{
id: 'new_id',
kind: 'tools',
description: ''
}
],
'$sort': { kind: 1 }
}
}
}
arrayFilters [
{ 'event.id': 'eid' },
{ 'touchpoint0.id': 'tpid0' }
]