PSA: New Promise-based IndexedDB.jsm module

Dão Gottwald dgottwald at mozilla.com
Sun Mar 26 09:03:38 UTC 2017


For those who are curious like me, it looks like extension meta data is our
first and so far only consumer of this:
https://bugzilla.mozilla.org/show_bug.cgi?id=1344590

Kris, what lead you to wanting to use IndexedDB here? What are the
tradeoffs compared to mozstorage or plain JSON (see sessionstore)?

dao

2017-03-26 4:27 GMT+02:00 Kris Maglione <kmaglione at mozilla.com>:

> A couple of weeks ago, I added a new Promise-based IndexedDB helper module
> as part of some performance work I was doing:
>
> http://searchfox.org/mozilla-central/source/toolkit/modules/IndexedDB.jsm
>
> If you've been avoiding IndexedDB because of the verbose and
> difficult-to-work-with API, I encourage you to give it a try. There are
> a lot of advantages to using IndexedDB for storage, particularly the fully
> async API and use of structured clone for data serialization. With this
> module, a basic database access is as simple as:
>
>  let db = await IndexedDB.open(
>    "fooDB", {storage: "persistent", version: 1}, db => {
>      db.createObjectStore("foo");
>    });
>
>  await db.objectStore("foo", "readwrite")
>          .set("bar", {baz: "quux"});
>
>  let val = await db.objectStore("foo").get("bar");
>
> Please let me know if you have any questions or suggestions.
>
> -Kris
> _______________________________________________
> firefox-dev mailing list
> firefox-dev at mozilla.org
> https://mail.mozilla.org/listinfo/firefox-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/firefox-dev/attachments/20170326/060b6736/attachment.html>


More information about the firefox-dev mailing list