Comparing version 0.7.0 to 0.7.1
@@ -617,3 +617,3 @@ // Generated by CoffeeScript 1.6.2 | ||
} | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, _this._refineRawInstance(model, result, options.select)); | ||
@@ -734,3 +734,3 @@ } else { | ||
} | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, result.map(function(record) { | ||
@@ -737,0 +737,0 @@ return _this._refineRawInstance(model, record, options.select); |
@@ -349,3 +349,3 @@ // Generated by CoffeeScript 1.6.2 | ||
if ((result != null ? result.length : void 0) === 1) { | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, _this._refineRawInstance(model, result[0], options.select)); | ||
@@ -429,3 +429,3 @@ } else { | ||
} else { | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, result.map(function(record) { | ||
@@ -432,0 +432,0 @@ return _this._refineRawInstance(model, record, options.select); |
@@ -348,3 +348,3 @@ // Generated by CoffeeScript 1.6.2 | ||
if ((rows != null ? rows.length : void 0) === 1) { | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, _this._refineRawInstance(model, rows[0], options.select)); | ||
@@ -423,3 +423,3 @@ } else { | ||
} else { | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, rows.map(function(record) { | ||
@@ -426,0 +426,0 @@ return _this._refineRawInstance(model, record, options.select); |
@@ -201,3 +201,3 @@ // Generated by CoffeeScript 1.6.2 | ||
result.id = id; | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, _this._refineRawInstance(model, result, options.select)); | ||
@@ -230,3 +230,3 @@ } else { | ||
}); | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, records.map(function(record) { | ||
@@ -233,0 +233,0 @@ return _this._refineRawInstance(model, record, options.select); |
@@ -289,3 +289,3 @@ // Generated by CoffeeScript 1.6.2 | ||
if ((result != null ? result.length : void 0) === 1) { | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, _this._refineRawInstance(model, result[0], options.select)); | ||
@@ -361,3 +361,3 @@ } else { | ||
} else { | ||
if (options.return_raw_instance) { | ||
if (options.lean) { | ||
return callback(null, result.map(function(record) { | ||
@@ -364,0 +364,0 @@ return _this._refineRawInstance(model, record, options.select); |
@@ -353,3 +353,3 @@ // Generated by CoffeeScript 1.6.2 | ||
ConnectionAssociation.prototype._fetchAssociatedBelongsTo = function(records, target_model, column, select, callback) { | ||
ConnectionAssociation.prototype._fetchAssociatedBelongsTo = function(records, target_model, column, select, options, callback) { | ||
var id, id_column, id_to_record_map, ids, query; | ||
@@ -378,2 +378,5 @@ | ||
} | ||
if (options.lean) { | ||
query.lean(); | ||
} | ||
return query.exec(function(error, sub_records) { | ||
@@ -400,2 +403,5 @@ if (error) { | ||
} | ||
if (options.lean) { | ||
query.lean(); | ||
} | ||
return query.exec(function(error, sub_record) { | ||
@@ -421,3 +427,3 @@ if (error) { | ||
ConnectionAssociation.prototype._fetchAssociatedHasMany = function(records, target_model, foreign_key, column, select, callback) { | ||
ConnectionAssociation.prototype._fetchAssociatedHasMany = function(records, target_model, foreign_key, column, select, options, callback) { | ||
var cond, ids, query; | ||
@@ -441,2 +447,5 @@ | ||
} | ||
if (options.lean) { | ||
query.lean(); | ||
} | ||
return query.exec(function(error, sub_records) { | ||
@@ -466,2 +475,5 @@ if (error) { | ||
} | ||
if (options.lean) { | ||
query.lean(); | ||
} | ||
return query.exec(function(error, sub_records) { | ||
@@ -479,8 +491,16 @@ if (error) { | ||
ConnectionAssociation.prototype.fetchAssociated = function(records, column, select, callback) { | ||
var association, record; | ||
ConnectionAssociation.prototype.fetchAssociated = function(records, column, select, options, callback) { | ||
var association, record, _ref; | ||
if (typeof select === 'function') { | ||
callback = select; | ||
options = {}; | ||
select = null; | ||
} else if (typeof options === 'function') { | ||
callback = options; | ||
options = {}; | ||
if (typeof select === 'object') { | ||
options = select; | ||
select = null; | ||
} | ||
} | ||
@@ -491,3 +511,3 @@ record = Array.isArray(records) ? records[0] : records; | ||
} | ||
association = record.constructor._associations[column]; | ||
association = (_ref = (options.model || record.constructor)._associations) != null ? _ref[column] : void 0; | ||
if (!association) { | ||
@@ -497,5 +517,5 @@ return callback(new Error("unknown column '" + column + "'")); | ||
if (association.type === 'belongsTo') { | ||
return this._fetchAssociatedBelongsTo(records, association.target_model, column, select, callback); | ||
return this._fetchAssociatedBelongsTo(records, association.target_model, column, select, options, callback); | ||
} else if (association.type === 'hasMany') { | ||
return this._fetchAssociatedHasMany(records, association.target_model, association.foreign_key, column, select, callback); | ||
return this._fetchAssociatedHasMany(records, association.target_model, association.foreign_key, column, select, options, callback); | ||
} else { | ||
@@ -502,0 +522,0 @@ return callback(new Error("unknown column '" + column + "'")); |
@@ -167,3 +167,3 @@ // Generated by CoffeeScript 1.6.2 | ||
Query.prototype.lean = function() { | ||
this._options.return_raw_instance = true; | ||
this._options.lean = true; | ||
return this; | ||
@@ -274,3 +274,6 @@ }; | ||
return async.forEach(_this._includes, function(include, callback) { | ||
return _this._connection.fetchAssociated(records, include.column, include.select, callback); | ||
return _this._connection.fetchAssociated(records, include.column, include.select, { | ||
model: _this._model, | ||
lean: _this._options.lean | ||
}, callback); | ||
}, function(error) { | ||
@@ -277,0 +280,0 @@ return callback(error, records); |
{ | ||
"name": "cormo", | ||
"description": "ORM framework for Node.js", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"keywords": [ | ||
@@ -35,4 +35,4 @@ "orm", | ||
"chai": "~1.9.0", | ||
"coffee-script": "~1.6.3", | ||
"crojsdoc": "~0.6.4", | ||
"coffee-script": "~1.7.1", | ||
"crojsdoc": "~0.6.5", | ||
"microtime": "~0.5.1", | ||
@@ -39,0 +39,0 @@ "mocha": "~1.17.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
240050
5693