indexeddb.io

0.5.0 • Public • Published

NPM version License Dependency status

indexeddb.io

  • Promise based API wrapper for indexeddb.

APIs

  • store

    • init

    • add

    • put

    • get

    • remove

    • find

    • findOne

    • findAndRemove

    • count

    • clear

  • index

Usage

import Store from 'indexeddb.io'
 
const store = new Store({
  db: 'test',
  store: {
    name: 'item',
    keyPath: 'id',
    autoIncrement: true
  },
  indexes: [{
    name: 'name',
    property: 'name',
    unique: true
  }]
})
 
let id
 
store.init().then(...)
 
// add
 
store.add({
  name: 'haoxin',
  desc: 'hello'
})
.then(result => {
  id = result
})
 
// get
 
store.get(id)
 
// put
 
store.put({
  id,
  name: 'haoxin',
  desc: 'hello world'
})
 
// findOne
 
store.findOne('name', 'haoxin')
 
// find
 
store.find()
 
store.find('name', IDBKeyRange.only('haoxin'))
 
// findAndRemove
 
store.findAndRemove('name', IDBKeyRange.only('haoxin'))
 
// remove
 
store.remove(id)

License

MIT

Package Sidebar

Install

npm i indexeddb.io

Weekly Downloads

4

Version

0.5.0

License

MIT

Last publish

Collaborators

  • coderhaoxin