How can I update these elements by their position (index)? I use dot notation test.0 for the first level, I access the first sublist of the list, but how can I access the elements of this sublist?
I’ve tried this approach but I get the error "Cannot create field " " in element " ".
I want to clarify that “test” is a nested field.
The first dot notation works, but not the second one.
{’$set’: {‘PARENT_TEST.$.test.0’: ‘99’} this doesn’t raise an error,
but this {’$set’: {‘PARENT_TEST.$.test.1.0’: “99”} does.
Sorry for not posting the actual data scheme, but it’s confusing because it’s embedded in Python code.
@BrainTrance_N_A, you can do the update using the array update operator $[<identifier>] (the link I had provided has the documentation about “filtered positional operator”).
Note that you need to specify a condition to identify the element of the array field vms to update. I used the "onoma": "nikolas" as the filter criteria. The query:
In the expression "vms.$[e].plirwmi.1.0", 1.0 represents the index positions of the array field plirwmi and the inner array. 1 is the second element of plirwmi array (index 1; array indexes start from 0). And, the 0 index is the inner array’s ([ '0' ] ) first element.
Although it works for the above scheme, it raises the same error in the original scheme which virtually has the same structure. I suppose I’ll have to check my code, something is different. In the context of the question your answer is an accepted solution. Thanks!