def get_all(cls, attr, value, is_list=False): client = mongo_meta_client collection_name = get_index_collection_name(cls, attr) db = client['indexdb'] if is_list: db_entities = db[collection_name].find({"value": {"$in": [value]}}) else: db_entities = db[collection_name].find({"value": value}) return [data_api.get(cls, db_entity['_id']) for db_entity in db_entities]
def get_one(cls, attr, value, is_list=False, projection=None): client = mongo_meta_client collection_name = get_index_collection_name(cls, attr) db = client['indexdb'] if is_list: db_entity = db[collection_name].find_one({"value": {"$in": [value]}}) else: db_entity = db[collection_name].find_one({"value": value}) if db_entity is None: return None return data_api.get(cls, db_entity['_id'], projection=projection)
def get_by_id(guid): return data_api.get(User, guid)
def update(user): db_user = data_api.get(User, user.id) db_user.__dict__.update(user.__dict__) return data_api.update(db_user)
def get_by_id(guid): return data_api.get(Article, guid)
def get_by_id(guid): return data_api.get(Company, guid)
def update(user_subscription): db_user_subscription = data_api.get(UserSubscription, user_subscription.id) db_user_subscription.__dict__.update(user_subscription.__dict__) return data_api.update(db_user_subscription)
def update(user_bucket): db_user_bucket = data_api.get(UserBucket, user_bucket.id) db_user_bucket.__dict__.update(user_bucket.__dict__) return data_api.update(user_bucket)