I want to find all documents that have "fecha" equal than today's date (considering 'today' is 2017-08-08). "Fecha" property is a string, so I tried this:
db.getCollection('operaciones').find({"fecha_registro": /^2017-08-08/});
It works good on robomongo so Ive been trying to send the "/^2017-08-08/" as a parameter to my api but no success.
Do you know a better way to achieve this? Maybe not send a parameter but use a function in mongo itself?
This are example documents:
{
"_id" : ObjectId("598910f600e65c6da6a9f643"),
"fecha" : "2017-08-08T01:16:38.783Z"
} {
"_id" : ObjectId("598910f600e65c6da6a9f644"),
"fecha" : "2017-08-08T01:23:21.183Z"
} {
"_id" : ObjectId("598910f600e65c6da6a9f645"),
"fecha" : "2017-08-09T01:52:31.313Z"
} {
"_id" : ObjectId("598910f600e65c6da6a9f646"),
"fecha" : "2017-08-09T04:36:01.512Z"
}
Thank you