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

317
Vistas
Count the number of items with a condition in MongoDB collection

I can't figure out what I'm doing wrong with my query. I want to get the number of "alertes" with the field "resolved: false" so my query is :

Alertes.find({resolved: false}).count();

But it returns me 0 despite I have 1 entry in the collection with the field resolved: false

Somone could help me to figure out what I'm doing wrong ?

enter image description here

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

0

I had forgot to subscribe to the collection in my IronRouter file :

Router.route('/', {
  name: 'home',
  waitOn: function() {
    return [
      Meteor.subscribe('infosContainers'),
      Meteor.subscribe('infosMachines'),
      Meteor.subscribe('alertes'),
    ];
  },
  fastRender: true,
});

Thank you for the help

over 4 years ago · Santiago Trujillo Denunciar

0

Did you try this?

Alertes.find({resolved: false}).fecth().length

If you are running this code at the client side, make sure you have subscribed to this collection, and that you have documents that satisfy the filter you are looking for. Try to query all documents (with no filter) to make sure the documents are there with the query above, and check what you get back:

Alertes.find().fecth()

If you don't find any documents with the resolved property set to false, then the query is returning correctly, and the problem is your subscription.

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