Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Commit

Permalink
moved operationsMap outside of function and class...++perf
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl Seguin committed May 6, 2012
1 parent 629f0b4 commit a94bed8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/query.js
Expand Up @@ -2,6 +2,8 @@ var util = require('util');
var _ = require('underscore')._;
var events =require('events');

var operationsMap = {'=': '=', '!': '!=', '>': '>', '<': '<', '>=': '>=', '<=': '<=', '!=' : '<>', '<>': '<>'};

var Query = function(sql, params, table) {
events.EventEmitter.call(this);
var self = this;
Expand Down Expand Up @@ -77,14 +79,13 @@ var Query = function(sql, params, table) {
var params = [];

if(_.isObject(conditions) &! _.isArray(conditions)) {
var operations = {'=': '=', '!': '!=', '>': '>', '<': '<', '>=': '>=', '<=': '<=', '!=' : '<>', '<>': '<>'};
var _conditions = [];
var seed = self.params.length;

_.each(conditions, function(value, key) {
var parts = key.trim().split(/ +/);
var property = parts[0];
var operation = operations[parts[1]] || '=';
var operation = operationsMap[parts[1]] || '=';

if (_.isBoolean(value) || _.isNumber(value)) {
_conditions.push(util.format('"%s" %s %d', property, operation, value));
Expand Down

0 comments on commit a94bed8

Please sign in to comment.