I have two separate MongoDB collections stock and sold.
I'd like to get all the entries in sold of certain stock types. The information for stock type is in another collection called stock, both have unique stock indexes.
Since I can't join in MongoDB, I am trying to query both collections. What is the best way to go about this?
I have tried:
cursor1 = db.stock.find({
"$or": [
{“Stock_Type": 1},
{“Stock_Type": 2},
{“Stock_Type": 3},
]
})
stock_id = []
for i in cursor:
stock_id.append(i.Stock_Index)
cursor2 = db.sold.find({
"$and": [
{“Stock_Index": {"$in": stock_id}},
{“Month”: “February},
{“Category”:5}
]
})
In the above case I get an internal server error:
AttributeError: 'dict' object has no attribute 'Stock_Index'
Thanks in advance for any responses.