Skip to content

Commit

Permalink
fix(create): prevent error while searching for last object
Browse files Browse the repository at this point in the history
If `res` was a nullish value, an error would be thrown here as the knex query would be malformed.
  • Loading branch information
citycide committed Dec 8, 2017
1 parent 251bb6d commit 5379bb5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Model {

return helpers.runQuery(this.ctx, query)
.then(() => helpers.findLastObject(this, object))
.then(res => res || this.findOne(object))
.then(res => res || (res != null && this.findOne(object)))
}

find (column, criteria, options = {}) {
Expand Down

0 comments on commit 5379bb5

Please sign in to comment.