I need to perform a query on a mongodb database that results in one result set per time range. I'm using pymongo. My query looks like this:
queryConsulta = {"$and": [
{"id_no": id_node},
{"porta": porta},
{"datahora":{"$gte": self.horaInicio}},
{"datahora": {"$lte": self.now}}
]}
listaResultados = db.minhacolecao.find(queryConsulta)
I've also tried it this way:
queryConsulta = {"id_no":int(id_node),
"porta":porta,
"datahora": {"$gte":self.horaInicio, "$lte":self.now }}
listaResultados = db.minhacolecao.find(queryConsulta)
But the result is always empty. I have tested directly on mongodb but the result is empty. I'm sure the data exists in the database with the time range I'm searching.