Beispiel #1
0
 def get_one_by_id(cls, collection_name, id):
     result = Database.find_one(collection=collection_name,
                                query={'_id': id})
     return cls(**result).to_json()
Beispiel #2
0
    def find_one(cls, collection_name, query):
        result = Database.find_one(collection=collection_name, query=query)
        if result:
            return cls(**result).to_json()

        return None
    def get_role(user_id):
        role = Database.find_one(ROLE_COLLECTION, {"user_id": user_id})

        if role:
            return Role(**role)
        return None