ArangoDB Model Events Not Fired with Repository
<p>I'm exporting a model as in the below:</p>

<pre><code>var Foxx = require("org/arangodb/foxx");
var myNewModel = Foxx.extend(
{ schema:{...} },
{
    beforeSave: function() { 
        throw new Error('reached before save');
    }
});
</code></pre>

<p>And using it in a controller as in:</p>

<pre><code>var FoxxRepo = require("org/arangodb/foxx").Repository;
...
app.POST(function(req, resp) {
  var instance = new myNewModel({...schemadata...});
  var repo = new FoxxRepo(collection, { model: myNewModel });
  repo.save(instance);
}
...
</code></pre>

<p>The only way I can get the beforeSave model event to respond to the repository event is by registering the function with the model instance via instance.on(...) before passing the instance to the repo.</p>

<p>There are some threads on this discussion, but they appear to date from when adding event registration was just getting underway. The documention, <a href="https://docs.arangodb.com/Foxx/Develop/Repository.html" rel="nofollow">here</a>, has an example showing event registration as I've shown here. My server version is 2.7.1.</p>

<p>Is there a way to add event handlers to a foxx model in the definition file and have the handlers included in the instance such that they listen for repository events or must I manually add all the handlers via model.on() each time I create a new data model instance?</p>