Open adamgins opened 9 years ago
I am having the same issue. I tested using the db.books.aggregate() MongoDB sample code from: http://docs.mongodb.org/manual/reference/operator/aggregation/out/
I wonder if the Mongo version is outdated on Meteor? Update: [MongoDb 2.6](http://docs.mongodb.org/manual/reference/operator/aggregation/out/ https://github.com/meteor/meteor/blob/devel/History.md) is supported
This is a mongodb version issue. As @KyleKing said, $out
comes with monogdb 2.6.x
You need to use a 2.6.x mongo for that.
Meteor still does not support it, but you can use it your own. Anyway, next meteor version have 2.6 support natively.
@arunoda $out is working for me on meteor 1.1.0.2 . However it is not reactive. Am I missing something? See my question here: http://stackoverflow.com/questions/31620268/why-is-mongo-aggregation-not-reactive-in-meteor
@adamgins see this issue: https://github.com/meteor/meteor/issues/4947
@keyscores thanks
@adamgins I know you posted a long time ago. How did you solve this?
As I only needed the reactive pub temporarily, I ended up getting results and placing in a client side colllection.
@KyleKing did you manage to get this to work somehow?
Guys, this is how to pass options like $out
: https://github.com/meteorhacks/meteor-aggregate#using-options
It was supported earlier.
@arunoda FYI From my post in the Mongo issue tracker: https://jira.mongodb.org/browse/SERVER-19958 Charlie Swanson: " An aggregate command with an $out stage will create a temporary collection while the aggregation pipeline is running, and then, once the pipeline is done, it will rename the temporary collection to the name specified in the $out stage. e.g. if you ran
db.foo.aggregate([{$out: 'bar'}]);
It would create a temporary bar.tmp.agg_out collection, and insert all the results from the pipeline into that collection. When the pipeline completes, it will rename bar.tmp.agg_out to bar, keeping all indices and options of the existing bar collection (if any).
This should explain the behavior you are seeing. If I understand your code correctly, Meteor is providing a framework to let you listen to events, such as a document being inserted into a collection, and it is not calling the callback when you use an aggregate() command? As a temporary workaround, could you verify that listening to those events on the ".tmp.agg_out" collection would work? "
HI,
I am getting an error
Unrecognized pipeline stage name: '$out'
I included
{ $out: "commentsPerResource" }
as my last pipeline stage.Sorry, I am a bit confusedL: @EventedMind mentioned that it could be a reactive publication... but then both you and he talk about it not being reactive. See http://joshowens.me/using-mongodb-aggregations-to-power-a-meteor-js-publication/
BTW, In my example, I am trying to group the latest 5 comments by a doc_id. I can get this to work with a nested Pipeline call, but it's not reactive, I thought I'd look for the easy way before I started to try and "observeChanges" etc..