-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi observers lookup bug : not firing a re-run of the aggregation #36
Comments
@DonJGo : It would be more helpful if you could provide your code, not mine. |
Hi Rob, If you prefer i'm filtering my observers with an organizationID field. // Exemple item in collection Organization
const Organization = {
_id: "12324567", // an auto generatedID by the database
name: "test",
}
// Exemple item in collection App. We could have multi app per organizationID
const App = {
_id: "1e12ffgg1234", // an auto generatedID by the database
name: "test",
organizationID: "12324567",
status: "active"
}
// There when i sub on organization with all related app I cannot do :
Meteor.publish("orgsWithApp", function (organizationID) {
ReactiveAggregate(this, Organization, [{
$lookup: {
from: "app",
localField: "_id",
foreignField: "organizationID",
as: "apps"
}
}], {
noAutomaticObserver: true,
observers: [
Organization.find({ _id: organizationID }),
App.find({ organizationID: organizationID, status: "active" })
]
});
}); I hope this new exemple will be more representative of my problem. |
I think I understand what you're trying to do. If I've followed your logic you're trying to use observers to control the evaluation of the pipeline. What I think you should be doing is changing your pipeline.
Maybe like this: Meteor.publish("orgsWithApp", function (organizationID) {
ReactiveAggregate(this, Organization, [{
$match: {
_id: organizationID
}
}, {
$lookup: {
from: "app",
localField: "_id",
foreignField: "organizationID",
as: "apps"
}
}], {
noAutomaticObserver: true,
observers: [
App.find({ organizationID: organizationID, status: "active" })
]
});
}); |
Yeah the match is ok to filter my data and i get the correct result on the first call. Moreover, in your exemple, as you have noAutomaticObserver: true, the main table Organization is no more observed. So any change on it wont trigger the re-run of the aggregate. Yesterday i tried to make it work with only one observer and the result was the same. |
This:
The only change your example code would have tracked was on a single document in the |
Hi Rob, Sorry for the delay i'm pretty busy these days. But when i use find query filters the data is never updated. |
Hi guys,
Package version : 1.3.0
Was enjoying your great job with your package while I encounter an issue. I would like to have time to dive into your project and push a PR but I don't have yet.
My data was never updated while using a lookup and specific observers like in this exemple
But while i was using the aggregate like following it was working but an update on the lookup collection was not firing a re-run of the aggregation.
So i dive into the aggregate.js code to understand why it was working with default parameters.
There I found that in the default case : the find() parameters were empty objects.
So my solution is to do this in order to re-run the aggregate also on observers :
I cannot find a way to make it works with find({ id: "1" }) parameters, maybe I am doing something wrong but i was doing the same as your exemple in the readme.
Don't hesitate to tell me the good way if i'm wrong.
I hope this could be help to resolve this issue and help those who could encouter it.
Best regards,
The text was updated successfully, but these errors were encountered: