在meteor mongoshell上我可以使用db.collection.group,但是从Meteor.methods我可以,因为Meteor不支持它.
我怎么能写一个类似于以下方法的方法:
db.orders.group({
keyf: function(doc) {return {year:doc.createdAt.toISOString().substring(0, 4)}},
initial: {months:{}},
reduce: function(order, result) {
var month = order.createdAt.getMonth()+1,
date = order.createdAt.getDate();
month = result.months[month] || (result.months[month] = {});
date = month[date] || (month[date] = []);
date.push(order);
},
cond: {$and: [{createdAt: {$gt: new Date("2015-01-01")}, createdAt: {$lt: new Date("2015-12-31")}}]}
})
Run Code Online (Sandbox Code Playgroud)
期望结果是按月分组的对象组,然后按月内的日期分组.
PS orders,是一个非常大的集合,我真的想在数据库中进行分组.
在1.0.4中关于rawCollection()的信息后,我尝试了这个:
collection = Orders.rawCollection();
params = {
keyf: function(doc) {return {year:doc.createdAt.toISOString().substring(0, 4)}},
initial: {months:{}},
reduce: function(order, result) {
var month = order.createdAt.getMonth()+1,
date = order.createdAt.getDate(); …Run Code Online (Sandbox Code Playgroud) 我想在Django项目中开始使用React组件.React仅用于项目的某些部分(例如一些过滤器,搜索框等).
我想回答其他类似的问题,但它不适合我,因为我不想使用python-webpack和特别js-host是因为它将运行额外的过程,很难配置和部署.
有谁知道如何使用React与Django的任何其他好的解决方案?