forked from AbirHasan2005/PyroFilesStoreBot
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
Latest commit
30 lines (27 loc) · 960 Bytes
/
Copy pathdatabase.py
File metadata and controls
30 lines (27 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# (c) @TeleRoid14
importdatetime
importmotor.motor_asyncio
classDatabase:
def__init__(self, uri, database_name):
self._client=motor.motor_asyncio.AsyncIOMotorClient(uri)
self.db=self._client[database_name]
self.col=self.db.users
defnew_user(self, id):
returndict(
id=id,
join_date=datetime.date.today().isoformat()
)
asyncdefadd_user(self, id):
user=self.new_user(id)
awaitself.col.insert_one(user)
asyncdefis_user_exist(self, id):
user=awaitself.col.find_one({'id':int(id)})
returnTrueifuserelseFalse
asyncdeftotal_users_count(self):
count=awaitself.col.count_documents({})
returncount
asyncdefget_all_users(self):
all_users=self.col.find({})
returnall_users
asyncdefdelete_user(self, user_id):
awaitself.col.delete_many({'id': int(user_id)})