# Dexie.addons

This array contains functions that add functionality to Dexie. An addon may register itself in Dexie.addons by using `Dexie.addons.push(fn)`. Example:

```javascript
import Dexie from 'dexie';

export function ForEachAddon (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:

```javascript
(function(){

	function ForEachAddon (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)

```javascript
import Dexie from 'dexie';
import 'dexie-syncable';

// db1 will have Dexie.Syncable
// (and its dependent module Dexie.Observable) activated.
var db1 = new Dexie("dbname");

// db2 will not have any addons activated
var db2 = new Dexie("dbname", {addons: []});
```

ES5:

```html
<script src="dexie.min.js"></script>
<script src="dexie-observable.min.js"></script>
<script src="dexie-syncable.min.js"></script>
<script>
    // db1 will have the addons activated automatically
    var db1 = new Dexie('dbname');
    // db2 will not have any addons activated
    var db2 = new Dexie('dbname', {addons: []}); 
</script>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dexiejs.typogram.co/dexie/dexie.addons.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
