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 ?
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
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.