Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var needsAutoField = true,
fields = require('ormnomnom/fields');
var meta = new ModelMeta(name, this);
this._meta = meta;
Object.keys(options).forEach(function(key) {
meta.addField(key, options[key]);
if(options[key].isPrimaryKey()) {
needsAutoField = false;
this.setPrimaryKey(options[key]);
}
}.bind(this));
if(needsAutoField) {
var autoField = fields.AutoField();
meta.addField('id', autoField);
this.setPrimaryKey(autoField);
}
};