#Pymongo

1 messages · Page 1 of 1 (latest)

gusty cedar
#

Good evening guys, I have a question I am using mongodb to save the warn and ban information of my bot. But I don't know how to access the information with pymongo. If anyone can help me I will be grateful.

The main idea is to count how many warns the user has (this is marked in purple).

collection.count_documents({"id_user": id_user, f"warns.{guild_id}": {"$exists": True}})
gusty cedar
amber hollow
#

Query using find one document and only return back the field that stores the value of warns /band

slow perch
#

This tutorial explains all the basic functions of mongodb pretty well
https://youtu.be/rE_bJl2GAY8

MongoDB is a simple and easy to use database. This tutorial will show you how to use MongoDB with python and the python module pymongo. Pymongo is the offical MongoDB API that allows for you to easily perfor mdatabse operations.

Please Note: This is simply the basics of MongoDB in python, it is meant to get you started and give you an introduct...

▶ Play video
#

But basically to fetch a users data you can use this-

obj = db.find_one({"_id":userid})

#

Here the "userid" would be your "ObjectId('....)" And I would recommend you to save user data with their user id instead

gusty cedar
#

count objects inside objects

#

that's what I need

somber pawn
#

are u using pymongo library? If so switch to motor bc of code blocking

sand robin
#

.tag close