forked from Umaidahmad01/FileStore
-
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.
remove sql support and added mongo db support
- Loading branch information
Showing
4 changed files
with
59 additions
and
13 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
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 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