0

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);
  }
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
TOTΣM
  • 47
  • 1
  • 7

1 Answers1

0

first remove the ".js" at the end of any javascript imports. if that doesn't do the trick i know first-hand meteorhacks:aggregate@1.3.0 works with the latest meteor (be sure to remove the other aggregate package you're using before testing). with meteorhacks:aggregate you shouldn't need to change your code in any way.

Karina Y
  • 1
  • 1
  • 3