Meteor - Is it possible to query the database for items with a field that are equal or less than a value?

StackOverflow https://stackoverflow.com/questions/22358223

  •  13-06-2023
  •  | 
  •  

Pregunta

In my Meteor app my items in the database have a createdOn field with a date object as the value. I'd like to query for all items that were created on or before a certain date.

Is there a way to match on items with a value equal or less than a value I provide? Or do I need to return all items and then loop through them and pick out the ones I need?

¿Fue útil?

Solución

Meteor uses mongodb as its database so you can just do this with the mongo operator $lt.

For example:

Posts.find({createdOn: {$lte: new Date()}});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top