'Get data function in Dexie is returning undefined

My function is simple. Create table, bulk put data and retriew object based on index.

const db = new Dexie('data');
const dataToInsert = [{id: "aaaa", name: "bbb"}]

function data() {
var exists = await Dexie.exists("data");
  if (!exists) {
    await db.version(1).stores({
      data: 'id,name'
    });
    await db.geo.bulkPut(dataToInsert);
  }
  var record = await db.geo.get("aaaa");
}

I can see everything is inserted. But GET function is returning:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'get')

Even db.geo is undefined... any idea why?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source