forked from KWICBOTS/File-sharing-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from SHABIN-K/main
Added mongo db support
- Loading branch information
Showing
8 changed files
with
106 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#(©)CodeXBotz | ||
|
||
|
||
|
||
|
||
import pymongo, os | ||
from config import DB_URI, DB_NAME | ||
|
||
|
||
dbclient = pymongo.MongoClient(DB_URI) | ||
database = dbclient[DB_NAME] | ||
|
||
|
||
user_data = database['users'] | ||
|
||
|
||
|
||
async def present_user(user_id : int): | ||
found = user_data.find_one({'_id': user_id}) | ||
if found: | ||
return True | ||
else: | ||
return False | ||
|
||
async def add_user(user_id: int): | ||
user_data.insert_one({'_id': user_id}) | ||
return | ||
|
||
async def full_userbase(): | ||
user_docs = user_data.find() | ||
user_ids = [] | ||
for doc in user_docs: | ||
user_ids.append(doc['_id']) | ||
|
||
return user_ids | ||
|
||
async def del_user(user_id: int): | ||
user_data.delete_one({'_id': user_id}) | ||
return |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters