i’m trying to use the $lookup operator without success in meteor 1.4.
If i try something like: Template.test.helpers({ rendered: function(){ var obj = mytestcollection.aggregate([ { $lookup: { from: "cat", localField: "test1", foreignField: "test2", as: "inventory_docs" } } ]) return obj } });
I get: TypeError: collection.aggregate is not a function
Probably i don’t know how to use it or i’m doing something wrong because if mongodb 3.2 is now fully supported i shouldn’t have these problems.
I’ve waited so long for this version of Meteor just to make joins without the help of external (old) packages…
Strange. I can confirm that it does work - I’m using aggregate (and $lookup) in a live project using the syntax you have above (other than calling it server-side).
Yes, I tried everything and it doesn’t work.
BTW it’s quite strange that we are the only ones interested on this operator…
It could be really useful to make complex applications.
Did you try the raw collection object?
I’m not able to get the expected result with it.
It seems strange that you needed to use rawCollection, while it’s working for me with the normal Mongo.Collection object (on the server).
In any case, glad it’s working - it’s dramatically faster for joins than the code I was using before - presumably because I can now avoid all of the traffic between the database and the server.
Are you using something like meteorhacks:aggregate? That package implements the extending of the Meteor standard collection object with the underlying rawCollection().aggregate() method, which I referred to in my linked post.