def remove(ctx, collection_id, property_): """Removes a collection""" get_session_project_client().collection.remove(identity=collection_id, property=property_) if property_: click.echo('Property removed') else: click.echo('Collection removed')
def update(ctx, collection_id, filter_, operation): """Update documents""" click.echo( 'Updated documents: %s' % get_session_project_client().documents.update( collection=collection_id, operation=operation, filter=filter_)['updated'])
def get_file(ctx, document_id, collection_id, property_): """Returns a file content""" with click.open_file('-', 'w') as stdout: for file_part in get_session_project_client().document.get_file( identity=document_id, collection=collection_id, property=property_): stdout.write(file_part)
def create(ctx, data, collection_id, pretty): """Creates a document""" echo_json(get_session_project_client().document.create( data=data, collection=collection_id, ), pretty=pretty)
def update(ctx, document_id, collection_id, data, property_, pretty): """Updates a document""" echo_json(get_session_project_client().document.update( data=data, collection=collection_id, identity=document_id, property=property_), pretty=pretty)
def update(ctx, collection_id, data, property_): """Updates a collection""" response = get_session_project_client().collection.update( identity=collection_id, data=data, property=property_) if property_: click.echo('Property updated') else: click.echo('Collection updated')
def upsert(ctx, collection_id, filter_, operation): """Update or insert document""" response = get_session_project_client().documents.upsert( collection=collection_id, filter=filter_, operation=operation) if response.get('upsertedId'): click.echo('Created document with identity %s' % response.get('upsertedId')) else: click.echo('Updated documents: %s' % response.get('updated'))
def save(ctx, collection_id, data, property_): """Saves a collection""" response = get_session_project_client().collection.save( identity=collection_id, data=data, property=property_) if property_: click.echo('Property saved') elif response['created']: click.echo('Collection created') else: click.echo('Collection updated')
def find(ctx, collection_id, filter_, text_, fields, fields_exclude, pretty, sort): """Find documents""" for document in get_session_project_client().documents.find( collection=collection_id, filter=filter_, text=text_, fields=fields, fields_exclude=fields_exclude, sort=sort): echo_json(document, pretty=pretty)
def count(ctx, collection_id, filter_, text_): """Number of documents""" click.echo(get_session_project_client().documents.count( collection=collection_id, filter=filter_, text=text_))
def remove(ctx, document_id, collection_id): """Removes a document""" get_session_project_client().document.remove(identity=document_id, collection=collection_id) click.echo('Document removed')
def create(ctx, data): """Creates a collection""" get_session_project_client().collection.create(data=data) click.echo('Collection created')
def count(ctx, filter_, text_): """Number of collections""" click.echo(get_session_project_client().collections.count(filter=filter_, text=text_))
def find(ctx, filter_, text_, pretty): """Find collections""" for collection in get_session_project_client().collections.find( filter=filter_, text=text_): echo_json(collection, pretty=pretty)
def get(ctx, document_id, collection_id, property_, pretty): """Returns a document""" echo_json(get_session_project_client().document.get( identity=document_id, collection=collection_id, property=property_), pretty=pretty)
def remove(ctx, collection_id, filter_): """Removes documents""" click.echo('Removed documents: %s' % get_session_project_client().documents.remove( collection=collection_id, filter=filter_)['deleted'])
def get(ctx, collection_id, pretty, property_): """Returns a collection""" echo_json(get_session_project_client().collection.get( identity=collection_id, property=property_), pretty=pretty)