本页还没有译文
本页 23 段还没译成日本語,下面显示的是英文原文。openDatabase
还没翻译译自英文(tanstack.com)本页 23 段都还没译
function openDatabase(
name,
version,
onUpgrade?,
idbFactory?,
onBlocked?): Promise<IDBDatabase>;Defined in: packages/db/src/indexed-db-wrapper.ts:94
Opens an IndexedDB database with the specified name and version. A blocked request stays pending until native success or error. The caller owns the returned connection and must close it when no longer needed.
Parameters
name
string
The name of the database to open
version
number
The version number of the database schema
onUpgrade?
(db, oldVersion, newVersion, transaction) => void
Optional callback that runs during the onupgradeneeded event. Use this to create object stores and indexes.
idbFactory?
IDBFactory
Optional IDBFactory for testing/mocking (defaults to window.indexedDB or globalThis.indexedDB)
onBlocked?
(event) => void
Optional diagnostic callback for native blocked events. The request stays pending.
Returns
Promise<IDBDatabase>
A promise that resolves to the IDBDatabase instance
Example
const db = await openDatabase('myApp', 1, (db, oldVersion, newVersion, transaction) => {
if (oldVersion < 1) {
db.createObjectStore('todos', { keyPath: 'id' })
}
})