List Items In An IndexedDB Database
NOTE
After writing this I found:
>https://github.com/jakearchibald/idb>https://github.com/jakearchibald/idb>
which I'm experimenting with and looks like I'll be using:
See The Stuff
This is how I'm getting a list of all the items for a specific data store in an IndexedDB database. Check the console for the output
JavaScript
let db
const DB_NAME = "Example_List_Items"
const DB_VERSION = 56
const DB_STORE_NAME = `widgets`
const DB_STORE_KEY = "id"
const
const
const
document.
Notes
- This page populates the data so there's something to list
-
The main focus of this page is the
listItems
function that expects adb
variable to be available with an open database connection - Took a while to figure this one out. I'm still a yellow belt with IndexedDB so feel free to check my work
References
This post has a lot in it, but it's structure didn't work very well for me. I've had to pull things out and make my own examples to figure out how things work
Docs about the connection for an IndexedDB. I was trying to figure out if .success()
is called after .upgradeneeded()
. I didn't see that in the docs, but that seems to be how things are working with the code
There's a bunch of stuff in here that I want to look at for things like how to clear storage. It has $
in front of somethings. Not sure if that means it's jQuery or not. I don't see that called, so I'm not sure