Skip to content

Commit

Permalink
Add Sequelize operator aliases (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Aug 25, 2018
1 parent e23b247 commit 32a8e8a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -11,6 +48,7 @@ module.exports = function (app) {
dialect: 'mssql',
host: hostname,
logging: false,
operatorsAliases,
define: {
freezeTableName: true
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down

0 comments on commit 32a8e8a

Please sign in to comment.