Permalink
Browse files

moved operationsMap outside of function and class...++perf

  • Loading branch information...
1 parent 629f0b4 commit a94bed8f3f833ac305f0ac999cfbd42d6bb28c4a Karl Seguin committed May 6, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/query.js
View
@@ -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;
@@ -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));

0 comments on commit a94bed8

Please sign in to comment.