I want to use a wildcard in a query to select all records from a collection.
I have tried to use *
and %
as a wildcard for matching zero or all characters.
But it doesn't work.
from pymongo import MongoClient
import datetime
client = MongoClient("mongodb://localhost:27017/")
database = client["local"]
collection = database["someDB"]
if flag = True:
ch = "Pass"
else:
ch = "*"
query = {}
query["Current Stage"] = ch
cursor = collection.find(query)
try:
for doc in cursor:
print(doc)
finally:
client.close()
It was expected that all entries from the collection come up when the Flag
is False
. I have tried "*"
and "%"
as matching character.