def fetch(db, user_id: str): json_string = db.hget(TABLE_USER, user_id) if not json_string: return None _dict = utils.unjsonify(json_string) return User(**_dict)
def fetch(db, card_box_id: str): json_string = db.hget(TABLE_CARDBOXES, card_box_id) if not json_string: return None _dict = utils.unjsonify(json_string) return CardBox(**_dict)
def fetch_all(db): dict_json_users = db.hgetall(TABLE_USER) if not dict_json_users: return [] users = [User(**utils.unjsonify(d)) for d in dict_json_users.values()] return users
def fetch(db, cardbox_id: str): if not cardbox_id: return None json_string = db.hget(TABLE_CARDBOXES, cardbox_id) if not json_string: return None return CardBox(**utils.unjsonify(json_string))
def fetch_all(db): dict_json_boxes = db.hgetall(TABLE_CARDBOXES) if not dict_json_boxes: return [] boxes = [CardBox(**utils.unjsonify(d)) for d in dict_json_boxes.values()] return boxes
def fetch(db, user_id: str): if not user_id: return None json_string = db.hget(TABLE_USER, user_id) if not json_string: return None return User(**utils.unjsonify(json_string))
def fetch_multiple_duels(db, duel_ids: list): if not duel_ids: return [] json_strings = db.hmget(TABLE_VS, *duel_ids) if not json_strings: return [] return [utils.unjsonify(json_string) for json_string in json_strings]
def fetch_duel(db, duel_id: str): if not duel_id: return None json_string = db.hget(TABLE_VS, duel_id) if not json_string: return None return utils.unjsonify(json_string)
def fetch_multiple(db, cardbox_ids: list): if not cardbox_ids: return [] json_strings = db.hmget(TABLE_CARDBOXES, *cardbox_ids) if not json_strings: return [] return [ CardBox(**utils.unjsonify(json_string)) for json_string in json_strings ]
def fetch_multiple(db, user_ids: list): if not user_ids: return [] json_strings = db.hmget(TABLE_USER, *user_ids) if not json_strings: return [] return [ User(**utils.unjsonify(json_string)) for json_string in json_strings ]