I have an Items collection of items that can contain other items.
First I insert a new item and then I modify the item that will be it’s parent (so that it has a reference to it’s new child).
Logging the DDP messages I get:
// adding the new item
DDP receive {msg: “added”, collection: “items”, id: “JzkM3J8BCfbdgwmDo”, fields: {…}}
// modifying the item that is it’s parent
DDP receive {msg: “changed”, collection: “items”, id: “4XXoMMAjYCzbhSp82”, fields: {…}}
The problem is that if I use Items.find().observeChanges’ callbacks and trace the calls I get an inverted call order sometimes:
// changed gets called first when it should be second
Items: changed: 4XXoMMAjYCzbhSp82
// added gets called second when it should be first
Items: added: JzkM3J8BCfbdgwmDo {parentItemId: “4XXoMMAjYCzbhSp82”}
Does anyone know if this is a bug or if callback order is not preserved by Mongo?
Thanks!