Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmijatovic/indexeddb
Testing indexed db operations in plain javascript
https://github.com/dmijatovic/indexeddb
Last synced: 10 days ago
JSON representation
Testing indexed db operations in plain javascript
- Host: GitHub
- URL: https://github.com/dmijatovic/indexeddb
- Owner: dmijatovic
- License: apache-2.0
- Created: 2024-07-07T09:20:09.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-07T19:02:13.000Z (7 months ago)
- Last Synced: 2024-11-13T16:54:09.967Z (2 months ago)
- Language: JavaScript
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IndexedDB
This is test for indexedDB operations. The interface is quite "old fashion" with events like `onsuccess`, `onerror`
## Onupgradeneeded
This is important event. `onupgradeneeded` is triggered w
`onupgradeneeded` is called when you change the db version, from no database to first version, first version to second version etc...
`onsuccess` is called each time you make a new request, even if the database schemas has not been changed.
## Create new object or alter structure
This can be only done in `onupgradeneeded`. This event is triggered by changing the database version.
## Write data to existing table
Writing data can be only done using `transaction`. Read the [documentation](https://developer.mozilla.org/en-US/docs/Web/API/IDBTransaction)
Transaction modes are `readonly`, `readwrite`, `versionchange`. [Read more in docs](https://developer.mozilla.org/en-US/docs/Web/API/IDBTransaction/mode)
## Check data object exist
To check we need to use contains see https://developer.mozilla.org/en-US/docs/Web/API/DOMStringList
```javascript
console.log("customers data found", db.objectStoreNames.contains("customers"))
```