Hello everyone, i am using nestjs mongoose, i am trying to update a list concatenating what is currenty in the document with the new given data.
what i have in my code(this is a simplified version) is this:
Query:
await this.sampleModel.bulkWrite(
collectors.map((collector) => ({
updateOne: {
filter: { master:"111" },
update: {
$set: {
collectorsWithError: {
$concatArrays: [
'$collectorsWithError',
[
{
collectorId: collector.id,
},
],
],
},
},
},
},
})),
Document:
{
"_id": {
"$oid": "67e1a7979bae1f4ef1c45a7e"
},
"master": "111",
"collectorsWithError": [{}],
"createdAt": {
"$date": "2025-03-24T18:42:31.619Z"
},
"updatedAt": {
"$date": "2025-03-24T18:42:31.619Z"
},
"__v": 0
}
for some reason the result of this operation is that collectorsWithError becomes an array with an empty object.
if i execute this query in mongo atlas it shows the new array with merged values, so i dont know what i am doing wrong, i tried using $push but it doesnt add the new items to the array.
thanks in advance!