bookshelf-camelcase
bookshelf-camelcase copied to clipboard
idAttribute with underscores fails
When you try to define model with custom id containing underscores model always uses insert
instead of update
method on save.
const Foo = bookshelf.Model.extend({
tableName: 'foos',
idAttribute: 'custom_foo_id',
...
});
This code broken:
// After a successful database save, the id is updated if the model was created
if (method === 'insert' && this.id == null) {
const updatedCols = {};
updatedCols[this.idAttribute] = this.id = resp[0];
const updatedAttrs = this.parse(updatedCols);
_.assign(this.attributes, updatedAttrs);
} else if (method === 'update' && resp === 0) {
if (options.require !== false) {
throw new this.constructor.NoRowsUpdatedError('No Rows Updated');
}
}
Which version of bookshelf-camelcase are you using?
1.1.4