We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
To add an additional object store, it is required to increase the database version. Therefore, I suggest the following fix
`async function openDatabase(databaseInfo: DatabaseInfo) { if (databaseInfo.version === null) { databaseInfo.version = undefined; } databaseInfo.keyPath ??= 'id';
try { const storeName = databaseInfo.storeName ?? databaseInfo.databaseName; const currentVersionConnection = await openDB(databaseInfo.databaseName); if (currentVersionConnection != null && !currentVersionConnection.objectStoreNames.contains(storeName)) { databaseInfo.version = currentVersionConnection.version + 1; currentVersionConnection.close(); const database = await openDB( databaseInfo.databaseName, databaseInfo.version, { upgrade(db) { const storeName = databaseInfo.storeName ?? databaseInfo.databaseName; if (!db.objectStoreNames.contains(storeName)) { db.createObjectStore( databaseInfo.storeName ?? databaseInfo.databaseName, { keyPath: databaseInfo.keyPath, }); } } }); return database; } return currentVersionConnection; } catch (e) { console.error(e); return null; }
}`
The text was updated successfully, but these errors were encountered:
No branches or pull requests
To add an additional object store, it is required to increase the database version. Therefore, I suggest the following fix
`async function openDatabase(databaseInfo: DatabaseInfo) {
if (databaseInfo.version === null) {
databaseInfo.version = undefined;
}
databaseInfo.keyPath ??= 'id';
}`
The text was updated successfully, but these errors were encountered: