IDBVersionChangeEvent: oldVersion-Eigenschaft
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die schreibgeschützte oldVersion
-Eigenschaft des
IDBVersionChangeEvent
-Interfaces gibt die alte Versionsnummer der
Datenbank zurück.
Wenn die geöffnete Datenbank noch nicht existiert, ist der Wert von oldVersion
0.
Wert
Eine Zahl, die eine 64-Bit-Ganzzahl enthält.
Beispiele
js
const dbName = "sampleDB";
const dbVersion = 2;
const request = indexedDB.open(dbName, dbVersion);
request.onupgradeneeded = (e) => {
const db = request.result;
if (e.oldVersion < 1) {
db.createObjectStore("store1");
}
if (e.oldVersion < 2) {
db.deleteObjectStore("store1");
db.createObjectStore("store2");
}
// etc. for version < 3, 4…
};
Spezifikationen
Specification |
---|
Indexed Database API 3.0 # dom-idbversionchangeevent-oldversion |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
oldVersion |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Siehe auch
- Verwendung von IndexedDB
- Transaktionen starten:
IDBDatabase
- Transaktionen verwenden:
IDBTransaction
- Einstellen eines Schlüsselbereichs:
IDBKeyRange
- Abrufen und Ändern Ihrer Daten:
IDBObjectStore
- Verwendung von Cursors:
IDBCursor
- Referenzbeispiel: To-do Notifications (Beispiel live ansehen).