Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Model.define = function(name, opts) {
var ModelInstance = function(data) {
ModelInstance._meta.decodeData(this, data);
};
ModelInstance.prototype = new Model(name, opts);
ModelInstance.objects = new Manager(ModelInstance);
ModelInstance.meta = function(opts) {
Object.keys(opts).forEach(function(key) {
this[key] = opts[key];
}.bind(this._meta));
};
ModelInstance._meta = ModelInstance.prototype._meta;
Model.events.emit('model', ModelInstance);
Model.events.emit('model:'+ModelInstance._meta.model_name, ModelInstance);
return ModelInstance;
};