In my experience with Meteor, what you need is collecting / converting a document . Some code that I tried to make relevant to your context (not tested).
Tests = new Mongo.Collection('tests', { transform: function(test) { test.successCount = function(){ return Results.find({ testId: test._id, success: true }).count(); }; test.failCount = function(){ return Results.find({ testId: test._id, success: false }).count(); }; return test;
Depending on the scale and traffic of your application, you will need to decide whether it will be a read, which will occur every time the requested test document is more or less expensive, and then it is written into the obvious success and failure of the test document itself.
pimbrouwers
source share