From 009f0792150767d7de1a4db04c26444f52d5b756 Mon Sep 17 00:00:00 2001 From: Bo Lingen Date: Thu, 24 Aug 2017 19:39:13 +0000 Subject: [PATCH] fix: always return promises in async functions `model`, `hasModel`, and `dropModel` are documented as returning promises but sometimes could return synchronously. --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 4317dcd..ac98f36 100644 --- a/src/index.js +++ b/src/index.js @@ -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) @@ -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) @@ -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)