Skip to content

Seeding the IDB Database

Sharmab edited this page Apr 28, 2020 · 3 revisions

The My Money Calendar app includes some functions that you can call in Devtools in order to seed your local IndexedDB object store with some sample income and expense transactions. I've been using this to quickly test the app without having to do a lot of manual data entry every time I wipe my local data.

Usage

You can run these functions from Devtools console when you're viewing any part of the My Money Calendar app. The functions are:

  • developer.seedTestData() - Seeds the local data store with a starting balance, a weekly paycheck, and several recurring expenses.
  • developer.clearTestData() - Completely empties the IDB object store that holds transactions. Despite the name, it doesn't just delete seed data. It wipes everything in the DB.

After seeding is successful, the app will look like this:

Seeded Application

Both functions are async and return promises.

Examples

Seed data and refresh the page:

await developer.seedTestData();
window.location.reload();

Clear all data and refresh:

await developer.clearTestData();
window.location.reload();

Seed Data File

You can modify what gets seeded by editing the cfgov/unprocessed/apps/mmt-my-money-calendar/js/seed-data.js file. This file is loaded as a dynamic import when you first call one of the above two functions, so by default it's not download by users when they use the app.

The functions in the developer namespace are defined in cfgov/unprocessed/apps/mmt-my-money-calendar/js/index.js, the app's main entrypoint.

Clone this wiki locally