Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers.
The mode read-only property of the IDBTransaction interface returns the current mode for accessing the data in the object stores in the scope of the transaction (i.e., is the mode to be read-only, or do you want to write to the object stores?) The default value is readonly.
An object defining the mode for isolating access to data in the current object stores: A string defining the mode for isolating access to data in the current object stores. The following values are available:
readonlyAllows data to be read but not changed.
readwriteAllows reading and writing of data in existing data stores to be changed.
versionchangeAllows any operation, including ones that delete and create object stores and indexes. This mode is for updating the version number of transactions if the need is detected when calling IDBFactory.open(). Transactions of this mode cannot run concurrently with other transactions. Transactions in this mode are known as upgrade transactions.
In the following code snippet, we open a read/write transaction on our database and add some data to an object store. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. At the end, we log the mode of the current transaction using mode. For a full working example, see our To-do Notifications app (view example live).
| Indexed Database API 3.0 # ref-for-dom-idbtransaction-mode① |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 3, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.