Search code examples
couchdbcouchbase-lite

Get deleted documents in local storage


I am using CouchBase Lite 1.4 with Android over CouchDB 1.6 I would like to list all the _deleted documents on my local database Once I get all I would like to purge it So

Map<String, Object> deleted  = null;

            Database master = CouchbaseManager.getInstance().getMasterDataBase();
            QueryOptions queryOptions =  new QueryOptions();
            queryOptions.setStartKey("_deleted");
            queryOptions.setEndKey("_deleted");

            try {
                deleted =  master.getAllDocs(queryOptions);
            } catch (CouchbaseLiteException e) {
                e.printStackTrace();
            }
            Log.i("deleted", "we have " + deleted.size());

With this code I am not getting anything . What I am doing wrong? enter image description here


Solution

  • You cannot get only the deleted docs via query, but you can query all documents with included delete doc and then filter with document.isDeleted().

    how to query with included deleted doc