diff --git a/lib/transformer.ts b/lib/transformer.ts index 6f6a138..0356d1b 100755 --- a/lib/transformer.ts +++ b/lib/transformer.ts @@ -3,6 +3,7 @@ import * as Sequelize from 'sequelize' import { FabrixApp } from '@fabrix/fabrix' import { FabrixModel } from '@fabrix/fabrix/dist/common' import { pickBy, isString, startsWith } from 'lodash' +import { SequelizeResolver } from './SequelizeResolver' export const Transformer = { BreakException: {}, @@ -182,6 +183,13 @@ export const Transformer = { const options = Transformer.getModelOptions(app, model) const schema = Transformer.getModelSchema(app, model) + if (!model.resolver || !model.resolver.connect) { + throw new Error(`${modelName} was set to use Sequelize but the resolver is missing "connect"`) + } + if (!(model.resolver instanceof SequelizeResolver)) { + throw new Error(`${modelName} is not a Sequelize Resolver`) + } + model.store = store model.migrate = migrate model.resolver.connection = connection diff --git a/package-lock.json b/package-lock.json index 6f4592b..8910a5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@fabrix/spool-sequelize", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e71ad4f..905671d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fabrix/spool-sequelize", - "version": "1.1.2", + "version": "1.1.3", "description": "Spool - Datastore Spool for Sequelize.js http://sequelizejs.com", "scripts": { "build": "tsc -p ./lib/tsconfig.release.json",