-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
indexedDB #153
Comments
courseopen databaseconst openRequest = indexedDB.open('db-name', 1)
openRequest.onupgradeneeded = function(e){
// e.oldVersion 现有版本
// indexedDB.open 里传的是期望版本
// 在 upgradeneeded 里进行结构改造
}
openRequest.onsuccess = function() {
const db = openRequest.result
}
openRequest.onerror = function() {
// process error
} object stores就是 Table / Collection
必须在 objectStore action
需要通过 CURD
query1.使用 key 进行 get / delete
使用 IDBKeyRange.bound / lowerBound / upperBound 创建区间 2.使用其他字段进行查询 需要手动创建索引 objectStore.createIndex(indexName, keyPath, options) 使用索引 objectStore.index(indexName).get / getAll 使用索引删除 // 根据索引字段查询 key
const key = objectStore.index(indexName).getKey(valOfIndexField)
// 根据 key 删除 object
objectStore.delete(key) |
上层库
level 有点复杂
重度使用需要 indexedDB wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: