This array contains functions that add functionality to Dexie. An addon may register itself in Dexie.addons by using Dexie.addons.push(fn). Example:
import Dexie from'dexie';exportfunctionForEachAddon (db) {// Makes it possible to use forEach() instead of each() on collections.db.Collection.prototype.forEach =db.Collection.prototype.each;}// Register the addon to be included by default (optional)Dexie.addons.push(ForEachAddon);
ES5:
(function(){functionForEachAddon (db) {// Makes it possible to use forEach() instead of each() on collections.db.Collection.prototype.forEach =db.Collection.prototype.each; }// Register the addon to be included by default (optional)Dexie.addons.push(ForEachAddon);})();
Using addons
Addons that register themselves to Dexie.addons (For example Dexie.Observable and Dexie.Syncable)
import Dexie from'dexie';import'dexie-syncable';// db1 will have Dexie.Syncable// (and its dependent module Dexie.Observable) activated.var db1 =newDexie("dbname");// db2 will not have any addons activatedvar db2 =newDexie("dbname", {addons: []});
ES5:
<scriptsrc="dexie.min.js"></script><scriptsrc="dexie-observable.min.js"></script><scriptsrc="dexie-syncable.min.js"></script><script>// db1 will have the addons activated automaticallyvar db1 =newDexie('dbname');// db2 will not have any addons activatedvar db2 =newDexie('dbname', {addons: []}); </script>