Answer the question
In order to leave comments, you need to log in
How to check collection for existence of _id with specified text?
How to check collection for existence of _id with specified text?
Example:
If name is not in the records (_id) of the collection, then everything is fine, if there is, then we print the message print("The record already exists!")
Answer the question
In order to leave comments, you need to log in
You can check the quantity
if db.test.count_documents({"_id": name}) > 0:
print("Уже существует")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question