Author: ygrego Date: 2015-04-15 12:21:45 +0000 (Wed, 15 Apr 2015) New Revision: 1192 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1192 Log: New methods: "and", "or" and "_cloneKeys". Modified: oipf/js/impl/model/Query.js Modified: oipf/js/impl/model/Query.js =================================================================== --- oipf/js/impl/model/Query.js 2015-04-15 11:02:29 UTC (rev 1191) +++ oipf/js/impl/model/Query.js 2015-04-15 12:21:45 UTC (rev 1192) @@ -21,13 +21,42 @@ } else { this._type = "undifferent"; } - + this._and = []; + this._or = []; this._field = field; this._comparison = comparison; this._value = value; if (count) { this._count = count; } + }, + + and: function(query) { + + var queryClone = this._cloneKeys(this); + queryClone._and && queryClone._and.push(query); + + return queryClone; + }, + + or: function(query) { + + var queryClone = this._cloneKeys(this); + queryClone._or && queryClone._or.push(query); + + return queryClone; + }, + + _cloneKeys: function(query) { + + var keys = Object.keys(query); + var newQuery = new Query(); + for (var i = 0, l = keys.length; i < l; i++) { + newQuery[keys[i]] = query[keys[i]]; + } + + return newQuery; + } }); \ No newline at end of file