3
I need to perform a query in a mongodb database that results in a set of results per time range. I am using pymongo. My consultation is as follows:
queryConsulta = {"$and": [
                    {"id_no": id_node}, 
                    {"porta": porta},
                    {"datahora":{"$gte": self.horaInicio}},                      
                    {"datahora": {"$lte": self.now}}
                    ]}
listaResultados = db.minhacolecao.find(queryConsulta)
I tried that way too:
queryConsulta = {"id_no":int(id_node),
                    "porta":porta,
                    "datahora": {"$gte":self.horaInicio, "$lte":self.now }}
listaResultados = db.minhacolecao.find(queryConsulta)
However 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.