0

I want to do some calculation based on aggregation query (sum, group etc). However I found out that I cannot do this by directly using the Meteorjs collections.

I am thinking of connecting the the database directly and use the normal MongoDB query (the one that can be used in the Mongo shell) and use the result to construct an object and return it to the client side.

How can I do this? Do I need to declare the connection like an external js script to connect to the database or there is already shortcut for this; for example calling some method to connect to the current Meteorjs database etc.

Also, what is the best practice?

Haikal Nashuha
  • 2,958
  • 7
  • 44
  • 67

1 Answers1

1

You should be able to do this pretty easily with the meteorhacks:aggregate package. Note that this only works on the server side (that seems fine given your question), and according to the documentation it's very lightweight.

You can also check out this blog post to see it in action.

Carson Moore
  • 1,287
  • 1
  • 8
  • 9