D
D
Dream2021-06-01 20:53:55
MongoDB
Dream, 2021-06-01 20:53:55

How to check if collection is empty MongoDB?

How to check if a collection in a database is empty? I use MongoDB
I tried to do it by type:

db = db.collection.find()
if db is None:
print("Пусто")
else:
print("Что-то")

If the question is not clear - write

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
monochromer, 2021-06-01
@dreameddd

db.collection.count()
https://docs.mongodb.com/manual/reference/method/d...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question