>>> lod = [{"name": "alice"}, {"name": "bob"}, {"name": "carol"}]
>>> my_filter = {"name": {"$in": ["alice", "carol"]}}
>>> magic_function(lod, my_filter)
[{'name': 'alice'}, {'name': 'carol'}]
感謝を自分でmagic_functionを実装します。 https://github.com/mongomock/mongomock
ここでは一例です:
def magic_function(lod,my_filter):
collection = mongomock.MongoClient().db.collection
for doc in lod:
collection.insert(doc)
res = collection.find(my_filter)
result = []
for doc in res:
del doc['_id']
result.append(doc)
return result
lod = [{"name": "alice"}, {"name": "bob"}, {"name": "carol"}]
my_filter = {"name": {"$in": ["alice", "carol"]}}
print(magic_function(lod, my_filter))
はそれが私が探していたまさにです、ありがとうございます。 – user3301993