Dexie.js
Dexie.js copied to clipboard
Typescript complain with compound ID
I tried to create a combound key using:
export interface Foo {
bar: string,
baz: string;
}
export class MyDexie extends Dexie {
foos!: EntityTable<Foo, '&[bar+baz]'>;
constructor(name : string) {
super(name);
this.version(1).stores({
foos: '&[bar+baz]', // Primary key and indexed props
});
}
}
but I get an error:
Error: Type '"bar+baz"' does not satisfy the constraint 'keyof Foo'.
foos!: EntityTable<Foo, '&[bar+baz]'>;
is this a bug or am I missing something?
EntityTable currently only supports single property primary keys. Try with Table<Foo, [string,string]> instead
Thanks, but then I guess I will not have type safety for insertion etc. I guess I'll just use an id, and then create an index to efficiently get it