def get_elements(protocol, data_type, data_scope, _id=None, **kwargs): storage = Middleware.get_middleware( protocol, data_type, data_scope, **kwargs ) storage.connect() return storage.get_elements(ids=_id) or []
def remove_elements( protocol, data_type, data_scope, _id=None, _filter=None, **kwargs ): storage = Middleware.get_middleware( protocol, data_type, data_scope, **kwargs ) storage.connect() storage.remove_elements(ids=_id, _filter=_filter)
def put_element( protocol, data_type, data_scope, _id=None, element=None, **kwargs ): storage = Middleware.get_middleware( protocol, data_type, data_scope, **kwargs ) storage.connect() if not storage.put_element(element, _id=_id): return HTTPError(500, 'Impossible to put element in storage')
def find_elements( protocol, data_type, data_scope, query=None, projection=None, limit=0, skip=0, sort=None, with_count=False, **kwargs ): storage = Middleware.get_middleware( protocol, data_type, data_scope, **kwargs ) storage.connect() total = storage.count_elements(query=query) result = storage.find_elements( query=query, projection=projection, limit=limit, skip=skip, sort=sort, with_count=with_count ) return result, total