function createObjectStore(
db,
storeName,
options?): IDBObjectStore;Defined in: packages/indexeddb-db-collection/src/wrapper.ts:179
Creates an object store during a database upgrade.
This function must be called within an onupgradeneeded callback (i.e., within a versionchange transaction). Calling it outside of an upgrade context will throw an error.
IDBDatabase
The IDBDatabase instance
string
The name of the object store to create
IDBObjectStoreParameters
Optional configuration for the object store (keyPath, autoIncrement)
IDBObjectStore
The created IDBObjectStore
Error if not called during a version change transaction
const db = await openDatabase('myApp', 1, (db) => {
createObjectStore(db, 'todos', { keyPath: 'id' })
createObjectStore(db, 'users', { keyPath: 'id', autoIncrement: true })
})