def get_from_db(cls, id): """get_from_db(str) -> return(obj) id : blog id Returns : object Takes a given blog id and returns the data of a single blog. The return data is in the form of an object. """ blog_data = db.find_one('blogs', id) # search the blog db and return one blog object based return cls(**blog_data)
def _get_info(cls, key, query): """_get_info(str, str) -> return(object) key : The key used to searched the database's index query : The query requested return: Returns an object A helper method that searches the database using a key in order to find infomation. If the information is found within the database's index it returns an object. i """ data = db.find_one("users", {key: query}) # returns a dictionary if found return cls(**data) if data else None # passes the dictionary in a class object