Skip to content

Commit

Permalink
fix batch bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Jan 16, 2017
1 parent ad05430 commit eefa216
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

* Fix bug in batch operations.

## 1.0.2

* Fix async race conditon
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ function AutoIndex (db, idb, reduce) {
} else if (operation.type === 'batch') {
// todo handle dels
var idxBatch = operation.array.filter(puts).map(function (opr) {
if (op.type === 'put') return extend(op, {key: reduce(operation.value), value: op.key})
}).filter(existyKeys)
idb.batch(idxBatch, cb)
if (opr.type === 'put') return extend(opr, {key: reduce(operation.value), value: opr.key})
})
idb.batch(idxBatch.filter(existyKeys), cb)
}
}

Expand Down

0 comments on commit eefa216

Please sign in to comment.