Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to extend collection documents with computed fields in Meteor?

We have information we need on the client which is computed on a document. Like for example the number of entries in an array.

More practically we have a document Workshop which helds an array of participants (user's _id). Now we want the Workshop.numberOfParticipants().

There is no need to transmit the whole array to the client, so where to calculate this value? Is it possible to add this value to the document "Workshop" as a field like the other data?

I like to circumvent the generation of a Template.workshop.numberOfParticipants().

like image 671
loomi Avatar asked Nov 22 '25 02:11

loomi


1 Answers

One option for the future is MongoDB's oddly-named aggregation framework. Queries written against the aggregate API can return documents with calculated fields.

Meteor core doesn't support aggregate queries yet, but it's on the wishlist.

like image 120
debergalis Avatar answered Nov 24 '25 23:11

debergalis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!