Transactional key/value interactions with IndexedDB
Last updated 2 years ago by tehshrike .
WTFPL · Original npm · Tarball · package.json
$ cnpm install small-indexeddb 
SYNC missed versions from official npm registry.


IndexedDB model

  • The browser exposes databases, identified by a string name
  • Databases contain object stores, identified by a string name
  • Object stores can have transactions applied to them with any number of read/write/delete actions

For now, this library ignores some IndexedDB features (version numbers, multiple object stores per database) for simplicity's sake.


import smallIndexedDb from 'small-indexeddb'

promise = smallIndexedDb(databaseName)

Returns a promise that resolves to a transaction function for the given database. The store will be created if it does not exist yet.

Under the hood, the store name will be the same as the database name.

promise = transaction(mode, callbackFunction)

mode must be either 'readonly', 'readwrite' or 'readwriteflush'.

callbackFunction will be called immediately with a single IDBObjectStore parameter.

Your callback function must return either an IDBRequest or an array of IDBRequests.

The returned promise will return the result of the single IDBRequest, or an array containing the results of all the requests you returned.

async function main() {
	const transaction = await smallIndexedDb('sweetness')

	await transaction(`readwrite`, idbStore => idbStore.put(`totally a`, `a`))

	const [ a, b ] = await transaction(`readonly`, idbStore => [

	console.log(a, b)



Current Tags

  • 2.0.0                                ...           latest (2 years ago)

3 Versions

  • 2.0.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.0                                ...           3 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
Dev Dependencies (6)

Copyright 2014 - 2016 © |