0.5.0 • Published 7 years ago

indexeddb.io v0.5.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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