Javascript 如何在meteor中反应聚合mongodb
我是流星队的新手。我已经确立了发布/订阅的概念。在反应性地执行聚合时,我面临以下错误 客户端代码: 服务器代码 刷新DDP缓冲写入时出现异常:错误:应找到要更改的文档 在Object.update()处 ...Javascript 如何在meteor中反应聚合mongodb,javascript,mongodb,meteor,Javascript,Mongodb,Meteor,我是流星队的新手。我已经确立了发布/订阅的概念。在反应性地执行聚合时,我面临以下错误 客户端代码: 服务器代码 刷新DDP缓冲写入时出现异常:错误:应找到要更改的文档 在Object.update()处 ... 提前感谢。您没有客户端收藏。此外,在调用此帮助程序之前,您需要先订阅 试试这个 import { Template } from 'meteor/templating'; import { ReactiveVar } from 'meteor/reactive-var'; import
提前感谢。您没有客户端收藏。此外,在调用此帮助程序之前,您需要先订阅 试试这个
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './main.html';
var clientReport = new Mongo.Collection('clientReport');
Meteor.subscribe("reportTotals");
Template.header.helpers({
'tasks': function () {
console.log("tasks helper called : ");
console.log(clientReport.find().fetch());
},
});
您也不需要管道,也不需要自动运行服务器代码,请尝试以下操作:
AtmData = new Mongo.Collection('atmdata');
Meteor.startup(() => {
// code to run on server at startup
/* AtmData.insert({
bottles_used: 123,
}); */
});
Meteor.publish("reportTotals", function() {
// Remember, ReactiveAggregate doesn't return anything
ReactiveAggregate(this, AtmData, [{
// assuming our Reports collection have the fields: hours, books
$group: {
'_id': null,
'bottles_used': {
// In this case, we're running summation.
$sum: '$bottles_used'
// $sum: 1
}
}
}], { clientCollection: "clientReport" });
});
您没有客户端集合。此外,在调用此帮助程序之前,您需要先订阅 试试这个
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './main.html';
var clientReport = new Mongo.Collection('clientReport');
Meteor.subscribe("reportTotals");
Template.header.helpers({
'tasks': function () {
console.log("tasks helper called : ");
console.log(clientReport.find().fetch());
},
});
您也不需要管道,也不需要自动运行服务器代码,请尝试以下操作:
AtmData = new Mongo.Collection('atmdata');
Meteor.startup(() => {
// code to run on server at startup
/* AtmData.insert({
bottles_used: 123,
}); */
});
Meteor.publish("reportTotals", function() {
// Remember, ReactiveAggregate doesn't return anything
ReactiveAggregate(this, AtmData, [{
// assuming our Reports collection have the fields: hours, books
$group: {
'_id': null,
'bottles_used': {
// In this case, we're running summation.
$sum: '$bottles_used'
// $sum: 1
}
}
}], { clientCollection: "clientReport" });
});
我在这里制作了一个NPM包:。其主要目的是在一定时间后发布昂贵的聚合值。希望对您有所帮助。我在这里制作了一个NPM包:。其主要目的是在一定时间后发布昂贵的聚合值。希望对你有帮助