Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are "group by" aggregation queries possible in Meteor, yet?

Tags:

meteor

Is a Mongo-style db.collection.group(...) query possible in Meteor, yet? I was hoping i could run something like this on the server (coffeescript):

Meteor.publish "top10", ->
    Records.group
        key: {name:true}
        reduce: (obj, agg) -> agg.count++
        initial: {count:0}
like image 859
Lloyd Avatar asked Jun 29 '12 18:06

Lloyd


1 Answers

Actually not yet.

Meteor uses node-mongo-native to do CURD in the server-side, whilst minimongo in the client-side. And Meteor keeps same API in the both side.

The document says -

In this release, Minimongo has some limitations:

...

findAndModify, upsert, aggregate functions, and map/reduce aren't supported.

However, node-mongo-native supports them, so I think Meteor just doesn't expose the related API for us. You can take a look at packages/mongo-livedata/mongo_driver.js, and help yourself.

like image 71
jifeng.yin Avatar answered Oct 03 '22 07:10

jifeng.yin