当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 | request.addEventListener( 'success' , function (event){
const db = event.target.result;
db.transaction(objectStoreName, wa);
const store = transaction.objectStore(objectStoreName);
}, false);
|
数据库的增删改查:
1 2 3 4 5 6 7 8 9 10 11 12 13 | store.add(obj);
store.put(obj);
store. delete (value);
store.clear();
const g = store.get(value);
g.addEventListener( 'success' , function (event){
}, false);
|
按索引查找数据
1 2 3 4 5 6 7 8 9 | const index = store.index(indexName);
const cursor = index.openCursor(range);
cursor.addEventListener( 'success' , function (event){
const result = event.target.result;
if (result){
result.value
result. continue ();
}
}, false);
|
按索引的范围查找数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | const index = store.index(indexName);
const cursor = index.openCursor(range);
range = IDBKeyRange.lowerBound(value, true)
range = IDBKeyRange.lowerBound(value, false)
range = IDBKeyRange.upperBound(value, isOpen)
IDBKeyRange.bound(value1, value2, isOpen1, isOpen2)
|
最后,自己封装了一个indexedDB的库,可以参考一下:duan602728596/IndexedDB
以上就是HTML5 IndexedDB本地储存的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
html5盒子模型的使用方法
h5中header标签应该如何使用
html5实战-svg的详解
h5实现桌面通知
总结html5表单(二) input type 各种输入, 各种用户选择,上传
配置h5的滚动条样式
websocket+mse――html5 直播技术解析
h5实现获取用户地理定位
如何学习html5
html5 input新增type属性color颜色拾取器的实例代码
更多相关阅读请进入《indexeddb》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » HTML5 IndexedDB本地储存