resume-api / testing.py
Nattyboi's picture
hot fix for leaderboard
048f218
raw
history blame
634 Bytes
from typing import List
from bson import ObjectId
from pymongo import MongoClient
from app import MONGO_URI
def get_all_users(user_id:str =None) -> List:
client = MongoClient(MONGO_URI)
db = client.crayonics
collection = db['users']
# Insert the document
if user_id==None:
results= collection.find()
if results:
result = [result for result in results]
return result
client.close()
else:
result = collection.find_one(filter={"_id":ObjectId(user_id.strip())})
return result
print(get_all_users(user_id="67c9b68678fbf39f4ed94e01"))