Given an array of values I need to search through a MongoDB collection and return the combined results without making multiple find calls to the database. I would like to make a single call to the database and get the combined results
This is what I currently do (not exactly but its similar):
searchArray = ["hi", "bye"]
for item in searchedArray:
db.collection.find({"Field": item})
The problem with this is that I cannot combine the results that each .find call returned. This approach is also making several .find calls to the database(one for every elements in the searchedArray). I would like to make a single call and get all the combined results back.
Is there any way to do something like this but with every element of a given array and get all the combined results back:
searchedArray = ["hi", "bye"]
results = db.collection.find({"Field": 'hi'} and {"Field": 'bye'})