Skip to content

Commit

Permalink
better change handling
Browse files Browse the repository at this point in the history
  • Loading branch information
stockulus committed Sep 7, 2016
1 parent 352717b commit 0fd4765
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/pouchdb-adapter-asyncstorage/src/bulk_docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand All @@ -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
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions packages/pouchdb-adapter-asyncstorage/src/changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0fd4765

Please sign in to comment.