-
-
Notifications
You must be signed in to change notification settings - Fork 641
Dexie.addons
David Fahlander edited this page Apr 16, 2015
·
11 revisions
This array contains functions that extends Dexie. An addon may register itself in Dexie.addons by using Dexie.addons.push(fn)
. Example:
(function(){
function ForEachAddon (db) {
// Makes it possible to use forEach() instead of each() on collections.
db.Collection.prototype.forEach = db.Collection.prototype.each;
}
Dexie.addons.push(ForEachAddon);
})();
If including Dexie as a AMD or CommonJS module, modules will not register themselves automatically.
When using requirejs:
require(['Dexie','Dexie.Observable','Dexie.Syncable'], function (Dexie, dexieObservable, dexieSyncable) {
var db1 = new Dexie('dbname', {
addons: [dexieObservable, dexieSyncable] // Always specify explicitely wich addons to include
});
var db2 = new Dexie('dbname'); // No addons will be active even though they were required.
});
But when using script includes:
<script src="Dexie.js"></script>
<script src="Dexie.Observable.js"></script>
<script src="Dexie.Syncable.js"></script>
<script>
var db1 = new Dexie('dbname'); // db1 will have the addons activated automatically
var db2 = new Dexie('dbname', {addons: []}); // db2 will not have any addon activated
</script>
Dexie.js - minimalistic and bullet proof indexedDB library