Is it possible to propagate changed values between collections? Like, 1 collection contains values that refer to a day and other collection that refers to a week and contains a sum of the daily values.
{
day: 1,
values: {
1: 0.2,
2: 0.3,
..
}
}
{
week: 1,
days: {
1: 0.9,
2: 0.3,
..
}
}
Is there a way that by changing the daily values, the weekly values are updated accordingly?
Hope I made myself clear, thanks in advance.
If you are looking for DB trigger then MongoDB doesnot support triggers. But your scenario can be addressed using Capped Collections and Tailable triggers or you can use the mongo trigger please see https://www.npmjs.com/package/mongo-triggers.
One of this approach will help you in solving your problem.
Reference: How to listen for changes to a MongoDB collection?
Hope it Helps!