From 15f11870c89714f700b451303875d99e5301540a Mon Sep 17 00:00:00 2001 From: Herman Klushin Date: Tue, 20 Jun 2017 18:41:15 +0300 Subject: [PATCH 1/2] Multi ORM support --- lib/build-waterline-ontology.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/build-waterline-ontology.js b/lib/build-waterline-ontology.js index 4a22c24..e511d91 100644 --- a/lib/build-waterline-ontology.js +++ b/lib/build-waterline-ontology.js @@ -30,9 +30,21 @@ module.exports = function buildWaterlineOntology(hook, sails, cb) { // First, instantiate a fresh, empty Waterline ORM instance. var freshOntology = new Waterline(); + //orm by default is Waterline + let defaultOrm = sails.config.models.defaultOrm || 'Waterline'; // Next, iterate through each normalized model definition and register it with Waterline // (using the `loadCollection()` method). _.each(hook.models, function _loadEachModelDefIntoWaterline(normalizedModelDef, identity) { + //check orm of model definition + if (normalizedModelDef.sequelize) { + normalizedModelDef.orm = 'Sequelize'; + } else { + normalizedModelDef.orm = normalizedModelDef.orm || defaultOrm; + } + if (normalizedModelDef.orm != 'Waterline') { + sails.log.silly('Model `%s` registered in %s (ORM)', identity, normalizedModelDef.orm); + return; + } // Create a Waterline "Collection" instance for each model, then register it w/ the ORM. sails.log.silly('Registering model `%s` in Waterline (ORM)', identity); freshOntology.loadCollection(Waterline.Collection.extend(normalizedModelDef)); From 1329b0cba3add312f0043f5c221e7b561d29ffe3 Mon Sep 17 00:00:00 2001 From: Herman Klushin Date: Tue, 20 Jun 2017 18:45:35 +0300 Subject: [PATCH 2/2] v1.0.10-2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 782e77e..422e4b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sails-hook-orm", - "version": "1.0.10-1", + "version": "1.0.10-2", "description": "The ORM hook from Sails core.", "main": "index.js", "scripts": {