Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

236
Vistas
Meteor - Mongo aggregate does not have $count stage

I am using meteorhacks:aggregate package to do Mongo aggregation in Meteor. I want to get the count at the last stage of the pipeline so I use this code:

Message.aggregate([
  {
    $match: {
      // ...
    }
  }, {
    $count: 'count'
  }
]);

It is pretty simple and should work, but I only get this error:

Exception while invoking method 'methodname' 
MongoError: Unrecognized pipeline stage name: '$count'
...

Please help, thanks.

Updated: this question is not duplicated as an editor suggested, my main intention is to find out why I can not use $count

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

$count is available in mongodb version 3.4. For previous versions, you will need to use $group over a constant field.

Message.aggregate([
  {
    $match: {
      // ...
    }
  }, {
    $group: {
      _id : null, 
      count : {$sum : 1}
    }
  }
]);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda