IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data. While Web Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution. This is the main landing page for MDN's IndexedDB coverage — here we provide links to the full API reference and usage guides, browser support details, and some explanation of key concepts.
注意 : IndexedDB API is powerful, but may seem too complicated for simple cases. If you'd prefer a simple API, try libraries such as localForage , dexie.js , ZangoDB , PouchDB , idb , idb-keyval , JsStore and lovefield that make IndexedDB more programmer-friendly.
注意 : Like most web storage solutions, IndexedDB follows a same-origin policy . So while you can access stored data within a domain, you cannot access data across different domains.
Operations performed using IndexedDB are done asynchronously, so as not to block applications. IndexedDB originally included both synchronous and asynchronous APIs. The synchronous API was intended for use only with Web 工作者 but was removed from the spec because it was unclear whether it was needed. However, the synchronous API may be reintroduced if there is enough demand from web developers.
There are a number of web technologies that store data of one kind or another on the client side (i.e. on your local disk). IndexedDB is most commonly talked about. The process by which the browser works out how much space to allocate to web data storage and what to delete when that limit is reached is not simple, and differs between browsers. Browser storage limits and eviction criteria attempts to explain how this works, at least in the case of Firefox.
To get access to a database, call
attribute of a
object. This method returns an
object; asynchronous operations communicate to the calling application by firing events on
workerobjects. This interface isn't part of the 2.0 specification.
indexedDBand is therefore the entry point for the API.
createIndex()'s optionalParameters .). This interface isn't part of the 2.0 specification.
This specification fires events with the following custom interface:
IDBVersionChangeEventinterface indicates that the version of the database has changed, as the result of an
IDBOpenDBRequest.onupgradeneededevent handler function.
An early version of the specification also defined the following, now removed, interfaces. They are still documented in case you need to update previously written code:
IDBFactory.openwithout also calling
IDBDatabase.setVersion), and the interface
IDBOpenDBRequestnow has the functionality of the removed
|Indexed Database API Draft||Recommendation|
|Indexed Database API 2.0||Recommendation||初始定义|