diff --git a/generators/connection/templates/sequelize-mssql.js b/generators/connection/templates/sequelize-mssql.js index 9ec4f7e3..fcb2fbd3 100644 --- a/generators/connection/templates/sequelize-mssql.js +++ b/generators/connection/templates/sequelize-mssql.js @@ -1,5 +1,42 @@ const url = require('url'); const Sequelize = require('sequelize'); +const { Op } = Sequelize; +const operatorsAliases = { + $eq: Op.eq, + $ne: Op.ne, + $gte: Op.gte, + $gt: Op.gt, + $lte: Op.lte, + $lt: Op.lt, + $not: Op.not, + $in: Op.in, + $notIn: Op.notIn, + $is: Op.is, + $like: Op.like, + $notLike: Op.notLike, + $iLike: Op.iLike, + $notILike: Op.notILike, + $regexp: Op.regexp, + $notRegexp: Op.notRegexp, + $iRegexp: Op.iRegexp, + $notIRegexp: Op.notIRegexp, + $between: Op.between, + $notBetween: Op.notBetween, + $overlap: Op.overlap, + $contains: Op.contains, + $contained: Op.contained, + $adjacent: Op.adjacent, + $strictLeft: Op.strictLeft, + $strictRight: Op.strictRight, + $noExtendRight: Op.noExtendRight, + $noExtendLeft: Op.noExtendLeft, + $and: Op.and, + $or: Op.or, + $any: Op.any, + $all: Op.all, + $values: Op.values, + $col: Op.col +}; module.exports = function (app) { const connectionString = app.get('mssql'); @@ -11,6 +48,7 @@ module.exports = function (app) { dialect: 'mssql', host: hostname, logging: false, + operatorsAliases, define: { freezeTableName: true }, diff --git a/generators/connection/templates/sequelize.js b/generators/connection/templates/sequelize.js index 90cc51a4..790b6338 100644 --- a/generators/connection/templates/sequelize.js +++ b/generators/connection/templates/sequelize.js @@ -1,10 +1,48 @@ const Sequelize = require('sequelize'); +const { Op } = Sequelize; +const operatorsAliases = { + $eq: Op.eq, + $ne: Op.ne, + $gte: Op.gte, + $gt: Op.gt, + $lte: Op.lte, + $lt: Op.lt, + $not: Op.not, + $in: Op.in, + $notIn: Op.notIn, + $is: Op.is, + $like: Op.like, + $notLike: Op.notLike, + $iLike: Op.iLike, + $notILike: Op.notILike, + $regexp: Op.regexp, + $notRegexp: Op.notRegexp, + $iRegexp: Op.iRegexp, + $notIRegexp: Op.notIRegexp, + $between: Op.between, + $notBetween: Op.notBetween, + $overlap: Op.overlap, + $contains: Op.contains, + $contained: Op.contained, + $adjacent: Op.adjacent, + $strictLeft: Op.strictLeft, + $strictRight: Op.strictRight, + $noExtendRight: Op.noExtendRight, + $noExtendLeft: Op.noExtendLeft, + $and: Op.and, + $or: Op.or, + $any: Op.any, + $all: Op.all, + $values: Op.values, + $col: Op.col +}; module.exports = function (app) { const connectionString = app.get('<%= database %>'); const sequelize = new Sequelize(connectionString, { dialect: '<%= database %>', logging: false, + operatorsAliases, define: { freezeTableName: true }