pouchdb-react-native icon indicating copy to clipboard operation
pouchdb-react-native copied to clipboard

allDocs returns ALL docs

Open alburdette619 opened this issue 8 years ago • 2 comments

pouch-react-native Version: 6.4.0 RN Version: 0.51.0 React Version: 16.0.0 Adaptor: asyncstorage DB: Couchbase Sync Gateway v1.2.0

Description:

Despite providing the keys option as an array of document id strings, all docs are returned when calling allDocs. This seems to include _design docs and any replicated docs, but possibly not _local docs. The issue was introduced in 6.4.0 as it does not replicate on 6.3.4.

Replication:

The following will return all docs in the local database on version 6.4.0.

createLocalDatabase() {
  // connect to the local database
  this.local = new PouchDB('local_db', {
    auto_compaction: true,
    adapter: 'asyncstorage',     
    revs_limit: 3,
  });
}

async bulkGet(docIds) {
  let getResults;
  const options = { include_docs: true, conflicts: true, keys: docIds };

  try {
    getResults = await this.local.allDocs(options);
  } catch (ex) {
    console.log(ex);
  }

  return getResults;
}

Expected Behavior:

As described in the PouchDB docs for allDocs, when using the keys option.

alburdette619 avatar Jan 11 '18 14:01 alburdette619

I am seeing the same bug too, also 6.4.0

jhau avatar Jan 19 '18 06:01 jhau

There is another one identical issue but on Cordova https://github.com/pouchdb/pouchdb/issues/7007. The issue seems to be introduced in some of 6.4.0 pouchdb libs. 6.3.4 works fine for me.

barbatus avatar Jan 19 '18 11:01 barbatus