meteor-reactive-aggregate
meteor-reactive-aggregate copied to clipboard
ReactiveAggregate() + collection.update() -> Error: Expected to find a document to change
I'm not sure if I'm doing something wrong or this is a bug. I've taken quite an effort to describe the problem on StackOverflow, so please allow me to simply link to my question there.
In short and for search engines:
Uncaught Error: Expected to find a document to change
at Object.update (collection.js:207)
at Object.store.<computed> [as update] (livedata_connection.js:310)
...
This (probably) gets thrown when ReactiveAggregate() tries to update the clientCollection. But I don't know what I'm doing wrong here.
I could get rid of the above mentioned error by manually giving an arbitrary string to the _id field. I had _id: 0 in the last aggregation stage before. However, contrary to the docs, simply omitting the _id field did not result in an automatic creation of this field by ReactiveAggregate().
So I did this:
...
},{
$project: {
_id: "whatTheFuckIsGoingOnHere", // Calm down, bro!
rankingList: 1,
product_keys: "$product_keys.product_keys"
}
}
], { clientCollection: "aggregatedProductRanking"})
I'm not sure whether I misunderstood the docs, or this is a bug. So I'm leaving this open for you guys. Thanks for this awesome package. Reactive Aggregations are the sh*t!