When I try to add a new item to the array inside MongoDB Realm, I get the following error:
[
"To resolve this issue please update or replace the document in MongoDB to make sure it abides by the schema.",
"Change Event Type: update",
"Namespace: app.CompanyLocation",
"Partition: dag1f7g7102aecdd3e9467711e",
"Document ID: ObjectID(\"61f7f74a2aecdd3e9467711f\")",
"Detailed Error: cannot insert link at index 7 of array at path { table: \"CompanyLocation\", fullPath: \"units\" }, array has 6 elements and backfilling nulls in array of links are not supported",
"Number of Unsyncable Documents: 1"
]
I can’t understand what this error message tells me, can someone help explain it?
The code causing it:
const newUnits = result.Shipment.Units[0].Unit.map(u => u._attributes.UID + u._attributes.PSN).flat();
console.log(newUnits);
if(importResult.success){
// Lägg till den som inventory på platsen.
context.services.get("mongodb-atlas")
.db("app")
.collection("CompanyLocation")
.updateOne(
{
_id: new BSON.ObjectId(place),
_partition: partition},
{
$push: {
units: {
$each: newUnits
}
}
}
)
console.log(newUnits);
}
Hi, I have actually been looking into this. At first glance it looks like it is works as designed from a different example I was looking at but this seems like it may be a bit different. I see that you have console.log() statements in that function, could you by chance send the contents of newUnits? If the information is sensitive, the main thing I am curious about is if there are nulls at the start of that list?
Quick update: I have actually figured out the issue (thanks to your reproduction) and it seems that it has to do with a change in how MongoDB reports changes in the newest version 5.0. Hoping to fix it up soon and will try to deploy it (likely sometime this next week)