I used below code.
from pymongo import MongoClient
client=MongoClient()
db=client.mydb
if db.mycollections.find({"name": 'Chinna',"password":'chinna11'}).count() > 0:
print("true")
else:
print("false")
but it return below an error,
DeprecationWarning: count is deprecated. Use Collection.count_documents instead.
if anyone know, please help..
Assuming you're not interested in the documents and only what to count the matching ones, replace.find() with.count_documents():
from pymongo import MongoClient
client=MongoClient()
db=client.mydb
if db.mycollections.count_documents({"name": 'Chinna',"password":'chinna11'}) > 0:
print("true")
else:
print("false")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.