def get_by_email(cls, email): """ given an email it returns the user object of the email given or raises an exception if the user is not found :param email: email of the user to find :return: user object """ user = Database.find_one(COLLECTION, {"email": email}) if user: return cls(**user) raise UserNotFoundException("El usuario con el correo dado no existe")
def get_by_id(cls, _id): user = Database.find_one(COLLECTION, {'_id': _id}) if user: return cls(**user)
def get_by_id(cls, _id): user = Database.find_one(COLLECTION, {'_id': _id}) if user: return cls(**user) raise UserNotFoundException( "El usuario con el token / id dado no existe.")