Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaError on indexed objects #1809

Open
MStapelfeldt opened this issue Oct 4, 2023 · 1 comment
Open

SchemaError on indexed objects #1809

MStapelfeldt opened this issue Oct 4, 2023 · 1 comment

Comments

@MStapelfeldt
Copy link

Hi there,
I have a pretty strange Error, and I can't find out why this happens. My db.js:

export const db = new Dexie('database');
db.version(1.4).stores({
  // Table to store badges which got loaded by #list_badges
  badges: "&rfid, project_id", // , label, global_id, valid_now, allowed_areas
});

list.svelte:

      for (const key in data) {
        // key has value of rfid id and is used as primary key in DB
        if (data.hasOwnProperty(key)) {
          const entry = data[key];
          // use put to update entries and add new items
          await db.badges.put({
            rfid: key,
            // project_id is set by svelte
            project_id: project_id,
            label: entry.label,
            global_id: entry.global_id,
            valid_now: entry.valid_now,
            allowed_areas: entry.allowed_area_ids,
          });
        }
      }
      await db.badges.where(project_id).notEqual(project_id).delete();

On .delete() I get the error name: 'SchemaError', message: 'KeyPath 467 on object store badges is not indexed'. I don't get why, because on stores({}) I declared the indexes (I think). Is this an issue of dexie/indexeddb or is it me?

@dfahlander
Copy link
Collaborator

Change the line:

await db.badges.where(project_id).notEqual(project_id).delete();

to

await db.badges.where('project_id').notEqual(project_id).delete();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants