Im building a python application that allows you to query data from mongoDB based on the start time and end time that the user puts in. I have been able to connect to mongoDB and put data there. I just cant seem to get the query right. I will show only the function in question because I know that connecting to the database isn’t the problem, only the query.
JavaScript
x
3
1
def query_from_to(self, begin, end):
2
self.collection.find("$and" : [ { "x" : {"$gte": begin } }, { "x" : {"$lte": end } } ])
3
Is this even possible?
Advertisement
Answer
Put this format in your function try:
JavaScript
1
9
1
collection.find([
2
{
3
"$Date" : {
4
"$gte": begin,
5
"$lte": end
6
}
7
}
8
])
9