Skip to content

Commit

Permalink
call update directly on knex instead of where. (#146)
Browse files Browse the repository at this point in the history
This change allows one to pass a middleawre that returns different knex
objects based on whatever it is an update/insert (write) or select
(read) to allow read-write replica setups.
  • Loading branch information
omeid authored and daffl committed Mar 6, 2018
1 parent 7daa8d6 commit 4b5d2e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class Service {
// NOTE (EK): Delete id field so we don't update it
delete newObject[this.id];

return this.db(params).where(this.id, id).update(newObject).then(() => {
return this.db(params).update(newObject).where(this.id, id).then(() => {
// NOTE (EK): Restore the id field so we can return it to the client
newObject[this.id] = id;
return newObject;
Expand Down

0 comments on commit 4b5d2e8

Please sign in to comment.