Open SolardiaX opened 5 months ago
I think we should change the args: Mapping[str, Any] signture of the update_many method to args: Mapping[str, Any] | Sequence[Mapping[str, Any]] and used as:
await Categories.find({
f"ancestors.{i}": val for i, val in enumerate(origin_children_ancestors)
}).update_many([{
"$set": {
"ancestors": {
"$concatArrays": [
new_children_ancestors,
{"$slice": ["$ancestors", len(origin_children_ancestors), {"$size": "$ancestors"}]}
]
}
}
}])
Currently, this script can be executed as expect but with issue hints in IDE.
Thank you for the catch. I'll pick this up on the next bug fixing session
Describe the bug When use find & update_many to replace array fields frist N elements with new elements, the command update the fields value to nest document not the expresssion calculated value
To Reproduce
Expected behavior "ancestors" field should be updated starts with "new_children_ancestors" array.
Additional context "ancestors" is wrong updated to a dict { "$concatArrays": [ new_children_ancestors, {"$slice": ["$ancestors", len(origin_children_ancestors), {"$size": "$ancestors"}]} ]}