jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.31k stars 356 forks source link

Typescript version : can not create several indexes ? #124

Closed jeromeSH26 closed 5 years ago

jeromeSH26 commented 5 years ago

IDB 4.0.4

The definition of DBSchema seems to prevent us from creating several indexes in the same store. Indexes is not an array of indextype.

This is OK

interface ICacheDB extends DBSchema {
    userFavorites: {
        value: IResuSearch;
        key: string;
        indexes: { key: string };
    };
}

this is wrong

interface ICacheDB extends DBSchema {
    userFavorites: {
        value: IResuSearch;
        key: string;
        indexes: [{ key: string }, { key2: string }, { key3: string }];
    };

Am I missing something ?

Rgds

justjake commented 5 years ago
interface ICacheDB extends DBSchema {
    userFavorites: {
        value: IResuSearch;
        key: string;
        indexes: { idx1: string, idx2: number, idx3: [string, number] }
    };
}
jakearchibald commented 5 years ago

Yep, that's the answer. Thanks @justjake!