Good morning.
Situation: I get Mongodb from a number of recordings to fit my parameters, example:
tasks_query = task_base.find({
"$and": [{
"order_id": x
}, {
"site": y
}, {
"category": z
}]
})
Then I need a few thousand times tsikljami go through this data in a loop, making the selection of the Cursor by a certain parameter, figuratively:
for task in task_query:
if task['order_id'] = 234:
return task['category']
The bottom line: I don't want to make a few thousand calls to the database, and I want to get one large sample into memory and then do iterations on it. But:
- If I make a sample from a database into a list of dictionaries, I need to test the whole sample for cycles, to find that very long and resource-intensive
- When turning to the dictionary will be +- the same for the indices in different samples are different.
Question: if I just save the resulting Mongo Cursor into a variable, then will I be able to draw samples from it using find() as usual from the base, without having to apply each time to the database?
If there is some another solution (e.g. another structure data supporting index) or have I missed something important, I would be grateful for any advice :)