Skip to content

Commit b37bb71

Browse files
committed
Defer open event until database handle is obtained and length read
1 parent 4c5defd commit b37bb71

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ Store.prototype._store = function (mode, cb) {
146146
})
147147
}
148148

149+
Store.prototype._open = function(cb) {
150+
var self = this
151+
this._getdb(function(db) {
152+
self._store('readonly', function (err, store) {
153+
backify(store.get(self.name + DELIM + "length"), function(err, ev) {
154+
self.length = ev.target.result || 0
155+
cb(null)
156+
})
157+
})
158+
})
159+
}
160+
149161
function backify (r, cb) {
150162
r.addEventListener('success', function (ev) { cb(null, ev) })
151163
r.addEventListener('error', cb)

0 commit comments

Comments
 (0)