- Promise based API wrapper for indexeddb.
-
store
-
init
-
add
-
put
-
get
-
remove
-
find
-
findOne
-
findAndRemove
-
count
-
clear
-
-
index
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)
MIT