I just want a simple grouping. I installed the aggregation function with meteor add sakulstra:aggregate but in every case it returns
TypeError: Respuesta.aggregate is not a function
I'm using Meteor 1.10.2 and React.
This is my server side method:
import Respuesta from "/imports/api/respuesta.js";
export const analysis = new ValidatedMethod({
name: "analysis",
validate: new SimpleSchema({
codigo: {
type: String
} //idContacto
}).validator(),
run(one) {
var pipeline = [
{ $match: { codigo: one.codigo } },
{ $group: { _id: "$rtatexto", total: { $sum: "$rtatexto" } } }
];
return Respuesta.aggregate(pipeline);
}
});
And this is the invocation in the client:
obtenerCantidad() {
const one = { codigo: "2" };
var ret = analysis.call(one, (err, res) => {
if (err) {
console.log(err);
}
});
console.log(ret);
}