From e720b188279439433fc861e7d8350d259ac6e0ab Mon Sep 17 00:00:00 2001 From: Martin Jesper Low Madsen Date: Thu, 14 Dec 2017 09:29:08 +0100 Subject: [PATCH] Fixes `sails.models` and `sails.adapters` references --- index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 539d9ca..5a111cb 100644 --- a/index.js +++ b/index.js @@ -136,16 +136,17 @@ module.exports = function (sails) { // (This particular timing-- before initialize()-- is for backwards compatibility. // Originally it was so that other hooks could mix in models/adapters. Note that // this behavior may change in a future version of Sails.) - if (!sails.hooks.orm.models) { - sails.hooks.orm.models = {}; - // Expose a reference to `hook.models` as `sails.models` - sails.models = sails.hooks.orm.models; + if (!sails.models) { + sails.models = {}; } - if (!sails.hooks.orm.adapters) { - sails.hooks.orm.adapters = {}; - // Expose a reference to `hook.adapters` as `sails.adapters` - sails.adapters = sails.hooks.orm.adapters; + // Expose a reference to `sails.models` as `hook.models` + sails.hooks.orm.models = sails.models; + + if (!sails.adapters) { + sails.adapters = {}; } + // Expose a reference to `sails.adapters` as `hook.adapters` + sails.hooks.orm.adapters = sails.adapters; // Look for the `connections` config, and if found, log a deprecation message // and move it to `datastores`.