From 0fd47656416482c4894290b0c2b05917cf68f775 Mon Sep 17 00:00:00 2001 From: stockulus Date: Wed, 7 Sep 2016 16:31:56 +0200 Subject: [PATCH] better change handling --- packages/pouchdb-adapter-asyncstorage/src/bulk_docs.js | 4 ++-- packages/pouchdb-adapter-asyncstorage/src/changes.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/pouchdb-adapter-asyncstorage/src/bulk_docs.js b/packages/pouchdb-adapter-asyncstorage/src/bulk_docs.js index a5ea0ed..05b57a4 100644 --- a/packages/pouchdb-adapter-asyncstorage/src/bulk_docs.js +++ b/packages/pouchdb-adapter-asyncstorage/src/bulk_docs.js @@ -113,7 +113,7 @@ export default function (db, req, opts, callback) { result: { ok: true, id: newDoc.id, - rev: newDoc.deleted ? '0-0' : newDoc.rev + rev: newDoc.rev } } } @@ -137,7 +137,7 @@ export default function (db, req, opts, callback) { result: { ok: true, id: newDoc.id, - rev: newDoc.deleted ? '0-0' : newDoc.rev + rev: newDoc.rev } } } diff --git a/packages/pouchdb-adapter-asyncstorage/src/changes.js b/packages/pouchdb-adapter-asyncstorage/src/changes.js index fb13024..5cb1111 100644 --- a/packages/pouchdb-adapter-asyncstorage/src/changes.js +++ b/packages/pouchdb-adapter-asyncstorage/src/changes.js @@ -31,6 +31,7 @@ export default function (db, api, opts) { const filter = filterChange(opts) const complete = opts.complete const onChange = opts.onChange + const processChange = opts.processChange db.storage.getKeys((error, keys) => { if (error) return complete(error) @@ -62,10 +63,12 @@ export default function (db, api, opts) { const results = [] let lastChangeSeq - for (let index = 0; index < docs.length && results.length <= limit; index++) { + for (let index = 0; index < docs.length; index++) { + if (limit && results.length > limit) break + const doc = docs[index] const data = dataObj[doc.id] - const change = opts.processChange(data, doc, opts) + const change = processChange(data, doc, opts) change.seq = doc.seq const filtered = filter(change)