Skip to content

Commit adaa365

Browse files
authored
Merge pull request #80 from paparomeo/symbol-operators
Symbol operators
2 parents fbb6db6 + b8419e6 commit adaa365

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/sqlHandler.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ var modelGenerators = {
1616

1717
var MIN_SERVER_VERSION = '1.10.0'
1818

19+
var Op = Sequelize.Op
20+
1921
class SqlStoreError extends Error {
2022
constructor (properties) {
2123
super()
@@ -56,6 +58,7 @@ SqlStore.prototype.initialise = function (resourceConfig) {
5658
} else {
5759
var database = self.config.database || resourceConfig.resource
5860
var sequelizeArgs = [database, self.config.username, self.config.password, {
61+
operatorsAliases: false,
5962
dialect: self.config.dialect,
6063
dialectOptions: self.config.dialectOptions,
6164
host: self.config.host,
@@ -307,11 +310,11 @@ SqlStore.prototype._scalarFilterElementToWhereObj = function (element) {
307310
var op = element.operator
308311
if (!op) return value
309312

310-
if (op === '>') return { $gt: value }
311-
if (op === '<') return { $lt: value }
313+
if (op === '>') return { [Op.gt]: value }
314+
if (op === '<') return { [Op.lt]: value }
312315

313-
var iLikeOperator = '$like'
314-
if (self.sequelize.getDialect() === 'postgres') iLikeOperator = '$iLike'
316+
var iLikeOperator = Op.like
317+
if (self.sequelize.getDialect() === 'postgres') iLikeOperator = Op.iLike
315318

316319
if (op === '~') {
317320
var caseInsensitiveEqualExpression = { }
@@ -337,7 +340,7 @@ SqlStore.prototype._filterElementToSearchBlock = function (filterElement) {
337340
if (filterElement.length === 1) {
338341
return whereObjs[0]
339342
}
340-
return { $or: whereObjs }
343+
return { [Op.or]: whereObjs }
341344
}
342345

343346
SqlStore.prototype._getSearchBlock = function (filter) {
@@ -516,7 +519,7 @@ SqlStore.prototype.search = function (request, callback) {
516519
}
517520

518521
/**
519-
Find a specific resource, given a resource type and and id.
522+
Find a specific resource, given a resource type and an id.
520523
*/
521524
SqlStore.prototype.find = function (request, callback) {
522525
var self = this

0 commit comments

Comments
 (0)