Search code examples
couchdbektorp

How can I delete all Documents with Ektorp in CouchDB


I'm trying to delete all the saved documents in CouchDB with Ektorp. A document can I delete so:

public void deleteDoc(Object o) {
    db.delete(o);
}

But for all Docs? can any help?

Thanks.


Solution

  • If you want to delete all docs, why don't you just drop the database?

    Or you can use the bulk operations in Ektorp:

    List<Object> bulkDocs = ...
    Sofa toBeDeleted = ...
    
    bulkDocs.add(BulkDeleteDocument.of(toBeDeleted));
    
    db.executeBulk(bulkDocs);
    

    read more here: http://ektorp.org/reference_documentation.html#d100e642