Skip to main content

IndexedDB

//Full example
const testApp = new springroll.Application({
features: {
userData: true
}
});

const openButton = document.querySelector('#open');

const dbName = document.querySelector('#dbName');
const storeName = document.querySelector('#storeName');
const version = document.querySelector('#version');

testApp.container.on('connected', async () => {
openButton.addEventListener('click', async () => {
//Open database call is also used to create new stores if required
let openResult = await springroll.UserData.IDBOpen(
dbName.value,
Number.parseInt(version.value),// Must be an integer, any other type may give unexpected results
{ stores: [{ storeName: storeName.value }] } // Additions parameter. Used to create new store
);

console.log(openResult);
});
});
UserData - IndexedDB README

How to use this example

  • Open Database
  • Delete a Store
  • Create a Record
  • Update a Record
  • Delete a Record
  • Read a Record
  • Delete a Database
  • Close Database
  1. Enter a value for Database Name and Store Name
  2. Optional: Enter 2 for DBVersion. The higher number is for ease of testing when deleting the database
  3. Click the "Open Database" button
  4. To see this database click the "Display Data" button
  5. Optionally you can view the database information inside the dev tools console by hitting "f12"
  6. Go to the Storage Tab, it may be hidden inside the >> menu
  7. Under Indexed BD > should be your database with the given store.