Comparing version 1.13.11 to 1.13.12
@@ -905,7 +905,49 @@ var util = require(__dirname+'/util.js'); | ||
(function(key) { | ||
Model.prototype[key] = function() { | ||
var query = new Query(this); | ||
query = query[key].apply(query, arguments); | ||
return query; | ||
} | ||
switch (key) { | ||
case 'orderBy': | ||
Model.prototype[key] = function() { | ||
var query = new Query(this); | ||
if ((arguments.length === 1) | ||
&& (typeof arguments[0] === 'string') | ||
&& (this._getModel()._indexes[arguments[0]] === true)) { | ||
query = query[key]({index: arguments[0]}); | ||
return query; | ||
} | ||
else { | ||
query = query[key].apply(query, arguments); | ||
return query; | ||
} | ||
} | ||
break; | ||
case 'filter': | ||
Model.prototype[key] = function() { | ||
var query = new Query(this); | ||
if ((arguments.length === 1) | ||
&& (util.isPlainObject(arguments[0]))) { | ||
var keys = Object.keys(arguments[0]); | ||
if ((keys.length === 1) && (this._getModel()._indexes[keys[0]] === true)) { | ||
query = query.getAll(arguments[0][keys[0]], {index: keys[0]}); | ||
return query; | ||
} | ||
else { | ||
query = query[key].apply(query, arguments); | ||
return query; | ||
} | ||
} | ||
else { | ||
query = query[key].apply(query, arguments); | ||
return query; | ||
} | ||
} | ||
break; | ||
default: | ||
Model.prototype[key] = function() { | ||
var query = new Query(this); | ||
query = query[key].apply(query, arguments); | ||
return query; | ||
} | ||
} | ||
})(key); | ||
@@ -912,0 +954,0 @@ } |
@@ -259,43 +259,5 @@ var Promise = require('bluebird'); | ||
(function(key) { | ||
switch (key) { | ||
case 'orderBy': | ||
Query.prototype[key] = function() { | ||
if ((arguments.length === 1) | ||
&& (typeof arguments[0] === 'string') | ||
&& (this._model._indexes[arguments[0]] === true)) { | ||
this._query = this._query[key]({index: arguments[0]}); | ||
return this; | ||
} | ||
else { | ||
return new Query(this._model, this._query[key].apply(this._query, arguments)); | ||
} | ||
} | ||
break; | ||
case 'filter': | ||
Query.prototype[key] = function() { | ||
if ((arguments.length === 1) | ||
&& (util.isPlainObject(arguments[0]))) { | ||
var keys = Object.keys(arguments[0]); | ||
if ((keys.length === 1) && (this._model._indexes[keys[0]] === true)) { | ||
this._query = this._query.getAll(arguments[0][keys[0]], {index: keys[0]}); | ||
return this; | ||
} | ||
else { | ||
return new Query(this._model, this._query[key].apply(this._query, arguments)); | ||
} | ||
} | ||
else { | ||
return new Query(this._model, this._query[key].apply(this._query, arguments)); | ||
} | ||
} | ||
break; | ||
default: | ||
Query.prototype[key] = function() { | ||
return new Query(this._model, this._query[key].apply(this._query, arguments)); | ||
} | ||
} | ||
Query.prototype[key] = function() { | ||
return new Query(this._model, this._query[key].apply(this._query, arguments)); | ||
} | ||
})(key); | ||
@@ -302,0 +264,0 @@ } |
{ | ||
"name": "thinky", | ||
"version": "1.13.11", | ||
"version": "1.13.12", | ||
"description": "RethinkDB ORM for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/thinky.js", |
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
146577
3183