cormo
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -25,3 +25,3 @@ // Generated by CoffeeScript 1.4.0 | ||
_buildWhere = function(schema, conditions, conjunction) { | ||
var is_objectid, key, keys, obj, sub_key, subs, value; | ||
var is_objectid, key, keys, obj, sub_key, subs, value, _ref, _ref1; | ||
if (conjunction == null) { | ||
@@ -67,6 +67,13 @@ conjunction = '$and'; | ||
switch (sub_key) { | ||
case '$gt' || '$lt' || '$gte' || '$lte': | ||
case '$gt': | ||
case '$lt': | ||
case '$gte': | ||
case '$lte': | ||
obj = {}; | ||
obj[key] = {}; | ||
obj[key][sub_key] = value[sub_key]; | ||
if (((_ref = schema[key]) != null ? _ref.type : void 0) === types.Date) { | ||
obj[key][sub_key] = new Date(value[sub_key]); | ||
} else { | ||
obj[key][sub_key] = value[sub_key]; | ||
} | ||
return obj; | ||
@@ -98,3 +105,7 @@ case '$contains': | ||
obj = {}; | ||
obj[key] = value; | ||
if (((_ref1 = schema[key]) != null ? _ref1.type : void 0) === types.Date) { | ||
obj[key] = new Date(value); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
@@ -101,0 +112,0 @@ } |
@@ -271,3 +271,3 @@ // Generated by CoffeeScript 1.4.0 | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, values); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, values); | ||
} | ||
@@ -324,3 +324,3 @@ return this._query(sql, values, function(error, result) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -359,3 +359,3 @@ if ((options != null ? options.orders.length : void 0) > 0 || order_by) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -378,3 +378,3 @@ return this._query(sql, params, function(error, result) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -381,0 +381,0 @@ return this._query(sql, params, function(error, result) { |
@@ -256,3 +256,3 @@ // Generated by CoffeeScript 1.4.0 | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, values); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, values); | ||
} | ||
@@ -303,3 +303,3 @@ return this._query(sql, values, function(error, result) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -337,3 +337,3 @@ if ((options != null ? options.limit : void 0) != null) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -358,3 +358,3 @@ return this._query(sql, params, function(error, result) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -361,0 +361,0 @@ return this._query(sql, params, function(error, result) { |
// Generated by CoffeeScript 1.4.0 | ||
(function() { | ||
var AdapterBase, SQLAdapterBase, | ||
var AdapterBase, SQLAdapterBase, types, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -9,2 +9,4 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
types = require('../types'); | ||
SQLAdapterBase = (function(_super) { | ||
@@ -24,4 +26,4 @@ | ||
SQLAdapterBase.prototype._buildWhere = function(conditions, params, conjunction) { | ||
var key, keys, op, sub_key, subs, value, values, | ||
SQLAdapterBase.prototype._buildWhere = function(schema, conditions, params, conjunction) { | ||
var key, keys, op, sub_key, subs, value, values, _ref, | ||
_this = this; | ||
@@ -33,3 +35,3 @@ if (conjunction == null) { | ||
subs = conditions.map(function(condition) { | ||
return _this._buildWhere(condition, params); | ||
return _this._buildWhere(schema, condition, params); | ||
}); | ||
@@ -46,5 +48,5 @@ } else if (typeof conditions === 'object') { | ||
case '$and': | ||
return this._buildWhere(conditions[key], params, 'AND'); | ||
return this._buildWhere(schema, conditions[key], params, 'AND'); | ||
case '$or': | ||
return this._buildWhere(conditions[key], params, 'OR'); | ||
return this._buildWhere(schema, conditions[key], params, 'OR'); | ||
} | ||
@@ -92,3 +94,7 @@ } else { | ||
} | ||
params.push(value); | ||
if (((_ref = schema[key]) != null ? _ref.type : void 0) === types.Date) { | ||
params.push(new Date(value)); | ||
} else { | ||
params.push(value); | ||
} | ||
return key.replace('.', '_') + op + this._param_place_holder(params.length); | ||
@@ -101,3 +107,3 @@ } | ||
obj[key] = conditions[key]; | ||
return _this._buildWhere(obj, params); | ||
return _this._buildWhere(schema, obj, params); | ||
}); | ||
@@ -104,0 +110,0 @@ } |
@@ -216,3 +216,3 @@ // Generated by CoffeeScript 1.4.0 | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, values); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, values); | ||
} | ||
@@ -261,3 +261,3 @@ return this._query('run', sql, values, function(error) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -293,3 +293,3 @@ if ((options != null ? options.limit : void 0) != null) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -312,3 +312,3 @@ return this._query('all', sql, params, function(error, result) { | ||
if (conditions.length > 0) { | ||
sql += ' WHERE ' + this._buildWhere(conditions, params); | ||
sql += ' WHERE ' + this._buildWhere(this._connection.models[model]._schema, conditions, params); | ||
} | ||
@@ -315,0 +315,0 @@ return this._query('run', sql, params, function(error) { |
{ | ||
"name": "cormo", | ||
"description": "ORM framework for Node.js", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "orm", |
136507
3598