Indexed Database API

from Wikipedia, the free encyclopedia

The Indexed Database API , or IndexedDB for short , is a programming interface that allows websites to save structured data in the browser using JavaScript . The standard is being developed by the World Wide Web Consortium and has been implemented in browsers since 2011.

Basic principles

In an IndexedDB database , websites can permanently store and read data from the user at the user's facility. Each domain has its own storage area; access to the data stored by another domain is not provided according to the same-origin policy . The size of the available memory depends on the browser; there is usually a fixed limit that cannot be exceeded and a soft limit from which the user must agree to the saving beforehand. In principle, the storage is permanent, but browsers offer their users the option of deleting stored data.

The database is an object database , usually JavaScript objects are stored, whereby one of the entries serves as a key via which the data can be queried again. Indexes can also be created for other entries in the stored objects to enable efficient searches.

The database is accessed asynchronously : The client makes a request and registers callback functions . As soon as the result of the request is certain, he will be informed about the corresponding events ; in the event of success, the requested data will be supplied, and in the event of an error, the reason. During access, transactions are used to ensure consistent data even if, for example, two tabs open at the same time make several independent accesses to the database.

Implementations

The exact implementation of the database is not specified, but a B-tree is recommended . All modern browsers support the standard, but since it is constantly being developed, it is not always in the current version. The interface is only partially implemented in Microsoft's browsers . With older browser versions, the API is sometimes still provided with a manufacturer prefix.

Alternatives

Web storage is a much simpler alternative to storing data. However, this offers fewer functions.

An alternative standard that provides a database that can be queried via SQL was the Web SQL Database. However, this standard was only implemented in a few browsers, so that its further development in favor of the IndexedDB was discontinued.

Today the PouchDB , the graph-based GunDB, as well as the reactive RxDB and many other Javascript databases, as well as other solutions like the Hood.ie library, are up to date.

For older browsers, the IndexedDB can be simulated using polyfills .

Web links

Individual evidence

  1. Raymond Camden: IndexedDB and Limits. April 17, 2015, accessed March 29, 2017 .
  2. a b Data protection at risk: Firefox does not delete local databases. In: heise Online . September 19, 2017, accessed on October 2, 2017 (Provides an overview of the status of the implementations of the various browsers).
  3. Can I use: IndexedDB. Retrieved March 29, 2017 (English).
  4. ^ Ian Hickson: Web SQL Database. Retrieved March 29, 2017 (English).
  5. Parashuram Narasimhan: Using IndexedDB API today - the IndexedDB polyfills. In: Mozilla Hacks. July 31, 2012, accessed March 29, 2017 .