IndexedDB in Firefox 4

This is a guest post from Ben Turner, one of the developers of IndexedDB for Firefox.

Mozilla is pleased to announce support for IndexedDB in the upcoming Firefox 4 Beta 9 and recent trunk nightlies. IndexedDB allows web apps to store large amounts of data on your local system (with your explicit permission, of course) for fast offline retrieval at a later time. We’re hoping that webmail, TV listings, and online purchase history will one day be as convenient to access offline as they are online.

Web developers who are interested in using this new feature are encouraged to read the IndexedDB primer on Mozilla Developer Network. The primer attempts to strip away some of the complexity in the specification, to discuss the most important concepts and provide simple examples. The truly hardcore are of course welcome to read the entire specification.

Keep in mind that IndexedDB is brand new and is not uniformly supported by all browsers, and please file bugs for any behavior that seems to contradict the specification!


11 comments

  1. Josh

    Are these databases synced on Firefox Sync? If not, are there plans to do this in the future?

    January 12th, 2011 at 11:49

  2. oxdef

    Why not HTML5’s Web SQL Database?

    January 12th, 2011 at 14:37

  3. Janet Swisher

    @oxdef: This earlier post on database APIs addresses that question. While the code in Firefox 4: An early walk-through of IndexedDB is now obsolete, it gives an idea of the differences in approach.

    January 12th, 2011 at 14:55

  4. treebat

    oxdef, it was for religious and petty reasons. it’s long been a done deal, though, and perhaps it would be wise for developers who want a powerful cross-platform client-side DB soon to write and/or use a library that abstracts both IndexedDB and Web SQL Database.

    January 12th, 2011 at 22:52

  5. anonymous

    Can it be deactivated or better, removed? I do not want another persistence layer, than the cookie store!

    January 13th, 2011 at 11:48

    1. alexleduc

      If you are using private browsing, the feature is disabled.

      January 18th, 2011 at 13:14

  6. alexleduc

    What I don’t understand is the difference between using that and local/gloabalStorage. Weren’t those intended for offline web apps to store data? Doesn’t having IndexedDB and this create 2 APIs to do the same thing?

    January 18th, 2011 at 13:25

    1. Dan

      The difference is in storing related data. With a key/value storage you’d have to pre- or postfix your variables to create some token relationship. With a DB you have tables with columns and rows, so storing and retrieving data is easier and standardized.

      January 19th, 2011 at 13:34

      1. alexleduc

        The IndexedDB primer linked in this article says “IndexedDB databases store key-value pairs.”

        January 20th, 2011 at 05:53

        1. Dan

          Eventually, yes. I admit I wasn’t completely on the point there.

          IndexedDB lets you store whole JS objects in databases, which each can have multiple key/value pairs stored within them. That gives you a means to group related data, and the indexing gives you a means to query the data. So it’s actually more like CouchDB than relational databases like MySQL for example.

          You could store objects with g/l storage, too, if you’d convert them to JSON for example (since everything is a string in g/l storage). But you couldn’t query it like you could with IndexedDB.

          January 21st, 2011 at 15:29

          1. alexleduc

            Thanks for the clarification.

            January 22nd, 2011 at 05:31

Comments are closed for this article.