当前第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删除的标签有哪些
html5 学习filereader接口代码实例分享9(图)
什么是websocket?解析h5中的websocket
解析html5应用程序缓存application cache
h5怎样唤醒app
利用html5自定义实现播放器代码分享
详细介绍7款炫酷的html5 canvas动画特效
详细介绍通过html5的drag和drop生成拓扑图片base64信息的案例
bootstrap与html5的区别是什么
h5项目开发ios插件功能的实例代码
更多相关阅读请进入《indexeddb》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » HTML5 IndexedDB本地储存