Skip to content

Commit

Permalink
fix: always return promises in async functions
Browse files Browse the repository at this point in the history
`model`, `hasModel`, and `dropModel` are documented as returning
promises but sometimes could return synchronously.
  • Loading branch information
Bo Lingen committed Aug 24, 2017
1 parent 8a24f69 commit 009f079
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Trilogy {

model (name, schema, options) {
if (this.definitions.has(name)) {
return this.definitions.get(name)
return Promise.resolve(this.definitions.get(name))
}

const model = new Model(this, name, schema, options)
Expand Down Expand Up @@ -82,7 +82,7 @@ class Trilogy {

hasModel (name) {
if (!this.definitions.has(name)) {
return false
return Promise.resolve(false)
}

const query = this.knex.schema.hasTable(name)
Expand All @@ -91,7 +91,7 @@ class Trilogy {

dropModel (name) {
if (!this.definitions.has(name)) {
return false
return Promise.resolve(false)
}

const query = this.knex.schema.dropTableIfExists(name)
Expand Down

0 comments on commit 009f079

Please sign in to comment.