GithubHelp home page GithubHelp logo

Comments (7)

dfahlander avatar dfahlander commented on June 13, 2024 6

Ok there's a space in the primary key "pubkey blocked". Haven't seen that before and i don't remember if that is valid in IndexedDB. Try with "pubkeyBlocked" or if blocked was meant to be a secondary index, "pubkey, blocked"

from dexie.js.

secondl1ght avatar secondl1ght commented on June 13, 2024

NOTE: I checked the Application tab in DevTools and noticed there is no database initiated, so this could be the root of the issue and not the data types. I am following this tutorial https://dexie.org/docs/Tutorial/Svelte using SvelteKit to setup my Dexie DB. I added the db.ts file (using TypeScript) as shown there.

from dexie.js.

secondl1ght avatar secondl1ght commented on June 13, 2024

Update: I have tried explicitly calling the db.open() method to ensure that the database is opened but I still receive the same DatabaseClosedError with nothing showing up in IndexedDB. I am not sure what I am doing differently from the tutorial to receive these errors...

from dexie.js.

secondl1ght avatar secondl1ght commented on June 13, 2024

I even tried using await on db.open() and the Promise resolves successfully but still it looks like no DB is opened and the error is thrown?

from dexie.js.

secondl1ght avatar secondl1ght commented on June 13, 2024

If this helps to debug here is a code snippet of my db.ts file:

export class MySubClassedDexie extends Dexie {
	conversations!: Table<Conversation>;

	constructor() {
		super('MyDB');
		this.version(1).stores({
			conversations: '&pubkey blocked' // Primary key and indexed props
		});
	}
}

export const db = new MySubClassedDexie();

from dexie.js.

secondl1ght avatar secondl1ght commented on June 13, 2024

Ah thanks a lot, I totally missed the , that is required. I was trying to set pubkey as the primary and blocked as another key. Sometimes it's the little things that take the longest to notice... It's working now. :)

from dexie.js.

dfahlander avatar dfahlander commented on June 13, 2024

Ah thanks a lot, I totally missed the , that is required. I was trying to set pubkey as the primary and blocked as another key. Sometimes it's the little things that take the longest to notice... It's working now. :)

Great to hear that it was the issue! Logging error.inner on the catched DatabaseClosedError would have revealed 'SyntaxError: Failed to execute 'createObjectStore' on 'IDBDatabase': The keyPath option is not a valid key path.'.

This reminds me that there might have been a good idea to let DatabaseClosedError.prototype.toString() reveal also the message from the inner exception (note to myself).

from dexie.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.