an append only list
list notes.md
1.1 kB · 20 lines
Markdown
at main

The basic pattern that IndexedDB encourages is the following:

Open a database. Create an object store in the database. Start a transaction and make a request to do some database operation, like adding or retrieving data. Wait for the operation to complete by listening to the right kind of DOM event. Do something with the results (which can be found on the request object). With these big concepts under our belts, we can get to more concrete stuff.

  • https://javascript.info/indexeddb
  • upgradeneeded event called on open db request if db is created or changed
  • onversionchange event needed in case two tabs are opened and one tab upgrades and other tab is now old version
  • onblocked if other browser has old version open and wont close

https://gist.github.com/pesterhazy/4de96193af89a6dd5ce682ce2adff49a

  • Safari only keeps IndexedDB after 7 days of inactivity

  • IndexedDB is lower level and clunkier than I'd like, let's try localStorage first?