| 1 | Find document with _id:1 | { _id:1, items:[{item:'apple', qty:5, status:'A'}, {item:'banana', qty:10, status:'B'} ] } | N/A | N/A | { _id:1, items:[{item:'apple', qty:5, status:'A'}, {item:'banana', qty:10, status:'B'} ] } |
| 2 | Filter array elements where status='A' using $[elem] | { _id:1, items:[{item:'apple', qty:5, status:'A'}, {item:'banana', qty:10, status:'B'} ] } | [{item:'apple', qty:5, status:'A'}] | N/A | { _id:1, items:[{item:'apple', qty:5, status:'A'}, {item:'banana', qty:10, status:'B'} ] } |
| 3 | Update qty to 100 for filtered elements | { _id:1, items:[{item:'apple', qty:5, status:'A'}, {item:'banana', qty:10, status:'B'} ] } | [{item:'apple', qty:5, status:'A'}] | qty set to 100 | { _id:1, items:[{item:'apple', qty:100, status:'A'}, {item:'banana', qty:10, status:'B'} ] } |
| 4 | Save updated document | { _id:1, items:[{item:'apple', qty:100, status:'A'}, {item:'banana', qty:10, status:'B'} ] } | N/A | N/A | { _id:1, items:[{item:'apple', qty:100, status:'A'}, {item:'banana', qty:10, status:'B'} ] } |
| 5 | Update complete | { _id:1, items:[{item:'apple', qty:100, status:'A'}, {item:'banana', qty:10, status:'B'} ] } | N/A | N/A | { _id:1, items:[{item:'apple', qty:100, status:'A'}, {item:'banana', qty:10, status:'B'} ] } |