是“分组依据"吗?Meteor 中的聚合查询可能吗? [英] Are "group by" aggregation queries possible in Meteor, yet?
问题描述
Mongo 风格的 db.collection.group(...)
查询在 Meteor 中可行吗?我希望我可以在服务器上运行这样的东西(coffeescript):
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}
推荐答案
实际上还没有.
Meteor 使用 node-mongo-native 在服务器端做 CURD,而在客户端使用 minimongo.并且 Meteor 在双方保持相同的 API.
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.
文档说-
在此版本中,Minimongo 有一些限制:
In this release, Minimongo has some limitations:
...
不支持 findAndModify、upsert、聚合函数和 map/reduce.
findAndModify, upsert, aggregate functions, and map/reduce aren't supported.
然而,node-mongo-native 支持它们,所以我认为 Meteor 只是没有为我们公开相关的 API.你可以看一下packages/mongo-livedata/mongo_driver.js,并帮助自己.
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.
这篇关于是“分组依据"吗?Meteor 中的聚合查询可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!