Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6
@@ -66,4 +66,10 @@ /* UNIQORM | ||
Find.prototype.execute = function(callback) { | ||
Find.prototype.execute = function(options, callback) { | ||
const self = this; | ||
if (typeof options === 'function') { | ||
callback = options; | ||
options = null; | ||
} | ||
if (!callback) | ||
@@ -74,8 +80,8 @@ return promisify.fromCallback(function(cb) { | ||
const query = this._prepareQuery(); | ||
const options = { | ||
const query = this._prepareQuery(options || {}); | ||
const queryOptions = { | ||
objectRows: true | ||
}; | ||
//console.log(query.generate().sql); | ||
query.execute(options, function(err, result) { | ||
query.execute(queryOptions, function(err, result) { | ||
if (err) | ||
@@ -91,11 +97,16 @@ return callback(err); | ||
Find.prototype.then = function(resolver) { | ||
return this.execute().then(resolver); | ||
Find.prototype.then = function(options, resolver) { | ||
if (typeof options === 'function') { | ||
resolver = options; | ||
options = null; | ||
} | ||
return this.execute(options).then(resolver); | ||
}; | ||
/** | ||
* @param {Object} options | ||
* @protected | ||
* @return {Object} | ||
*/ | ||
Find.prototype._prepareQuery = function() { | ||
Find.prototype._prepareQuery = function(options) { | ||
const self = this; | ||
@@ -105,2 +116,3 @@ const model = self._model; | ||
var orderColumns; | ||
options.validateFields = options.validateFields || (this._model.orm.options.validateFields); | ||
@@ -114,4 +126,7 @@ /* Prepare select column list */ | ||
const field = model.fields[name]; | ||
if (!field) | ||
if (!field) { | ||
if (!options.validateFields) | ||
return; | ||
throw new ArgumentError('Model (%s) has no field (%s)', model.name, name); | ||
} | ||
const alias = (m[2] || name); | ||
@@ -118,0 +133,0 @@ selectColumns[alias] = { |
@@ -52,3 +52,4 @@ /* UNIQORM | ||
this.options = options || { | ||
caseSensitive: false | ||
caseSensitive: false, | ||
validateFields: true | ||
}; | ||
@@ -151,3 +152,4 @@ } | ||
/* Create model class */ | ||
const className = camelCase(m[1]) + camelCase(m[2]) + 'Model'; | ||
const className = camelCase(m[1].replace(/_/g, '')) + | ||
camelCase(m[2].replace(/_/g, '')) + 'Model'; | ||
const _super = Model; | ||
@@ -154,0 +156,0 @@ const ctor = function Model() { |
{ | ||
"name": "uniqorm", | ||
"description": "Easy to use, multi-dialect ORM framework for JavaScript", | ||
"version": "1.0.0-alpha.5", | ||
"version": "1.0.0-alpha.6", | ||
"author": "Panates Ltd.", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
46453
1719