New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mingo

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mingo - npm Package Compare versions

Comparing version 0.6.4 to 0.6.5

5

CHANGELOG.md
Changelog
=========
Changes between releases are kept here beginning from v0.5.0
Changes starting from v0.5.0 are tracked here
## v0.6.5 / 2016-07-04
- Fix incorrect de-duping of Date types in $sort aggregate operator. See [issue#23](https://github.com/kofrasa/mingo/pull/23)
## v0.6.4 / 2016-05-19

@@ -7,0 +10,0 @@ - Support matching against user-defined types. See [issue#22](https://github.com/kofrasa/mingo/issues/22)

92

mingo.js

@@ -1,2 +0,2 @@

// Mingo.js 0.6.4
// Mingo.js 0.6.5
// Copyright (c) 2016 Francis Asante <kofrasa@gmail.com>

@@ -14,3 +14,3 @@ // MIT

Mingo.VERSION = '0.6.3';
Mingo.VERSION = '0.6.5';

@@ -864,17 +864,19 @@ // backup previous Mingo

modifiers.reverse().forEach(function (key) {
var indexes = [];
var grouped = _.groupBy(collection, function (obj) {
var value = resolve(obj, key);
indexes.push(value);
return value;
var grouped = groupBy(collection, function (obj) {
return resolve(obj, key);
});
indexes = _.sortBy(_.uniq(indexes), function (item) {
var sortedIndex = {};
var findIndex = function (k) { return sortedIndex[hashcode(k)]; }
var indexKeys = _.sortBy(grouped.keys, function (item, i) {
sortedIndex[hashcode(item)] = i;
return item;
});
if (sortKeys[key] === -1) {
indexes.reverse();
indexKeys.reverse();
}
collection = [];
_.each(indexes, function (item) {
Array.prototype.push.apply(collection, grouped[item]);
_.each(indexKeys, function (item) {
Array.prototype.push.apply(collection, grouped.groups[findIndex(item)]);
});

@@ -2104,3 +2106,3 @@ });

* @param collection
* @param fn
* @param fn {function} to compute the group key of an item in the collection
*/

@@ -2114,24 +2116,18 @@ function groupBy(collection, fn) {

var lookup = {};
_.each(collection, function (obj) {
var key = fn(obj);
var h = hashcode(key);
var index = -1;
if (_.isObject(key)) {
for (var i = 0; i < result.keys.length; i++) {
if (_.isEqual(key, result.keys[i])) {
index = i;
break;
}
}
} else {
index = _.indexOf(result.keys, key);
}
if (index > -1) {
result.groups[index].push(obj);
} else {
if (_.isUndefined(lookup[h])) {
index = result.keys.length;
lookup[h] = index;
result.keys.push(key);
result.groups.push([obj]);
result.groups.push([]);
}
index = lookup[h];
result.groups[index].push(obj);
});

@@ -2147,2 +2143,44 @@

// encode value to a unique string form that is easily reversable
function encode(value) {
if (_.isNull(value)) {
return "null";
} else if (_.isUndefined(value)) {
return "undef";
} else {
var type = value.constructor.name;
switch (type) {
case "Boolean":
return "b|" + value.toString();
case "String":
return "s|" + value.toString();
case "RegExp":
return "r|" + value.toString();
case "Number":
return "n|" + value.toString();
case "Date":
return "d|" + value.toISOString();
case "Array":
return "a|" + JSON.stringify(_.map(value, function (v) { return encode(v); }));
case "Object":
return "o|" + JSON.stringify(_.mapObject(value, function (v) { return encode(v); }));
default:
return type + "|" + JSON.stringify(_.mapObject(value, function (v) { return encode(v); }));
}
}
}
// http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery
// http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
function hashcode(value) {
var hash = 0, i, chr, len, s = encode(value);
if (s.length === 0) return hash;
for (i = 0, len = s.length; i < len; i++) {
chr = s.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash.toString();
}
/**

@@ -2149,0 +2187,0 @@ * Returns the result of evaluating a $group operation over a collection

@@ -1,2 +0,2 @@

!function(r,n){"use strict";function t(r){for(var n=0;n<v.length;n++)if(v[n](r))return!0;return!1}function e(r){return t(r)||!p.contains($,r.constructor.name)}function i(r){if(e(r))return p.isRegExp(r)?{$regex:r}:{$eq:r};if(p.isObject(r)){var n=p.keys(r),t=0===p.intersection(a(R),n).length;if(t)return{$eq:r};if(p.contains(n,"$regex")){var i=r.$regex,u=r.$options||"",o="";p.isString(i)&&(o+=i.ignoreCase||u.indexOf("i")>=0?"i":"",o+=i.multiline||u.indexOf("m")>=0?"m":"",o+=i.global||u.indexOf("g")>=0?"g":"",i=new RegExp(i,o)),r.$regex=i,delete r.$options}}return r}function u(r,n){return p.result(r,n)}function o(r,t){if(!t)return n;for(var e,i=t.split("."),s=r,a=0;a<i.length;a++){if(e=null===i[a].match(/^\d+$/),e&&p.isArray(s)){var c=[];p.each(s,function(r){c.push(o(r,i[a]))}),s=c}else s=u(s,i[a]);if(s===n)break}return s}function s(r,n){return new Array(Math.max(n-String(r).length+1,0)).join("0")+r}function a(r){return p.keys(F[r])}function c(r,n){var t={keys:[],groups:[]};if(p.each(r,function(r){var e=n(r),i=-1;if(p.isObject(e)){for(var u=0;u<t.keys.length;u++)if(p.isEqual(e,t.keys[u])){i=u;break}}else i=p.indexOf(t.keys,e);i>-1?t.groups[i].push(r):(t.keys.push(e),t.groups.push([r]))}),t.keys.length!==t.groups.length)throw new Error("assert groupBy(): keys.length !== groups.length");return t}function f(r,t,e){if(p.contains(a(P),t))return O[t](r,e);if(p.isObject(e)){var i={};for(var u in e)if(p.has(e,u)&&(i[u]=f(r,u,e[u]),p.contains(a(P),u))){if(i=i[u],p.keys(e).length>1)throw new Error("Invalid $group expression '"+JSON.stringify(e)+"'");break}return i}return n}function l(r,n,t){if(p.contains(a(T),t))return C[t](r,n);if(p.isString(n)&&n.length>0&&"$"===n[0])return o(r,n.slice(1));var i;if(e(n))return n;if(p.isArray(n))i=p.map(n,function(n){return l(r,n,null)});else if(p.isObject(n)){i={};for(var u in n)if(p.has(n,u)&&(i[u]=l(r,n[u],u),p.contains(a(T),u))){if(i=i[u],p.keys(n).length>1)throw new Error("Invalid aggregation expression '"+JSON.stringify(n)+"'");break}}return i}var h,p,y={};y.VERSION="0.6.3",null!=r&&(h=r.Mingo),y.noConflict=function(){return r.Mingo=h,y};var g="undefined"!=typeof module&&"undefined"!=typeof require;g?("undefined"!=typeof module&&(module.exports=y),p=require("underscore")):(r.Mingo=y,p=r._);var v=[p.isString,p.isBoolean,p.isNumber,p.isDate,p.isNull,p.isRegExp,p.isUndefined],$=["Object","Array"],d={key:"_id"};if(y.setup=function(r){p.extend(d,r||{})},y.Query=function(r,n){return this instanceof y.Query?(this._criteria=r,this._projection=n,this._compiled=[],void this._compile()):new y.Query(r,n)},y.Query.prototype={_compile:function(){if(!p.isEmpty(this._criteria)){if(p.isArray(this._criteria)||p.isFunction(this._criteria)||!p.isObject(this._criteria))throw new Error("Invalid type for criteria");for(var r in this._criteria)if(p.has(this._criteria,r)){var n=this._criteria[r];if(p.contains(["$and","$or","$nor","$where"],r))this._processOperator(r,r,n);else{n=i(n);for(var t in n)p.has(n,t)&&this._processOperator(r,t,n[t])}}}},_processOperator:function(r,n,t){if(!p.contains(a(R),n))throw new Error("Invalid query operator '"+n+"' detected");this._compiled.push(E[n](r,t))},test:function(r){for(var n=0;n<this._compiled.length;n++)if(!this._compiled[n].test(r))return!1;return!0},find:function(r,n){return new y.Cursor(r,this,n)},remove:function(r){for(var n=[],t=0;t<r.length;t++)this.test(r[t])||n.push(r[t]);return n}},g){var m=require("stream").Transform,w=require("util");y.Query.prototype.stream=function(r){return new y.Stream(this,r)},y.Stream=function(r,n){return this instanceof y.Stream?(n=n||{},p.extend(n,{objectMode:!0}),m.call(this,n),void(this._query=r)):new y.Stream(r,n)},w.inherits(y.Stream,m),y.Stream.prototype._transform=function(r,n,t){if(p.isObject(r)&&this._query.test(r))if(p.isEmpty(this._query._projection))this.push(r);else{var e=new y.Cursor([r],this._query);e.hasNext()&&this.push(e.next())}t()}}y.Cursor=function(r,n,t){return this instanceof y.Cursor?(this._query=n,this._collection=r,this._projection=t||n._projection,this._operators={},this._result=!1,void(this._position=0)):new y.Cursor(r,n,t)},y.Cursor.prototype={_fetch:function(){var r=this;if(this._result!==!1)return this._result;if(p.isObject(this._projection)&&p.extend(this._operators,{$project:this._projection}),!p.isArray(this._collection))throw new Error("Input collection is not of valid type. Must be an Array.");this._result=p.filter(this._collection,this._query.test,this._query);var n=[];if(p.each(["$sort","$skip","$limit","$project"],function(t){p.has(r._operators,t)&&n.push(p.pick(r._operators,t))}),n.length>0){var t=new y.Aggregator(n);this._result=t.run(this._result,this._query)}return this._result},all:function(){return this._fetch()},first:function(){return this.count()>0?this._fetch()[0]:null},last:function(){return this.count()>0?this._fetch()[this.count()-1]:null},count:function(){return this._fetch().length},skip:function(r){return p.extend(this._operators,{$skip:r}),this},limit:function(r){return p.extend(this._operators,{$limit:r}),this},sort:function(r){return p.extend(this._operators,{$sort:r}),this},next:function(){return this.hasNext()?this._fetch()[this._position++]:null},hasNext:function(){return this.count()>this._position},max:function(r){return O.$max(this._fetch(),r)},min:function(r){return O.$min(this._fetch(),r)},map:function(r){return p.map(this._fetch(),r)},forEach:function(r){p.each(this._fetch(),r)}},y.Aggregator=function(r){return this instanceof y.Aggregator?void(this._operators=r):new y.Aggregator(r)},y.Aggregator.prototype={run:function(r,n){if(!p.isEmpty(this._operators))for(var t=0;t<this._operators.length;t++){var e=this._operators[t],i=p.keys(e);if(1!=i.length||!p.contains(a(Y),i[0]))throw new Error("Invalid aggregation operator '"+i+"'");i=i[0],r=n instanceof y.Query?_[i].call(n,r,e[i]):_[i](r,e[i])}return r}},y.find=function(r,n,t){return new y.Query(n).find(r,t)},y.remove=function(r,n){return new y.Query(n).remove(r)},y.aggregate=function(r,n){if(!p.isArray(n))throw new Error("Aggregation pipeline must be an array");return new y.Aggregator(n).run(r)},y.addOperators=function(r,n){var t=n({resolve:o,computeValue:l,ops:a,key:function(){return d.key}});if(!p.contains([T,P,Y,B,R],r))throw new Error("Could not identify type '"+r+"'");var e=a(r);p.each(p.keys(t),function(n){if(!/^\$\w+$/.test(n))throw new Error("Invalid operator name '"+n+"'");if(p.contains(e,n))throw new Error("Operator "+n+" is already defined for "+r+" operators")});var i={};switch(r){case R:p.each(p.keys(t),function(r){i[r]=function(n,t){return function(e,i){return{test:function(u){var s=o(u,e),a=n.call(t,e,s,i);if(p.isBoolean(a))return a;if(a instanceof y.Query)return a.test(u);throw new Error("Invalid return type for '"+r+"'. Must return a Boolean or Mingo.Query")}}}}(t[r],t)});break;case B:p.each(p.keys(t),function(r){i[r]=function(r,n){return function(t,e,i){var u=o(t,i);return r.call(n,i,u,e)}}(t[r],t)});break;default:p.each(p.keys(t),function(r){i[r]=function(r,n){return function(){var t=Array.prototype.slice.call(arguments);return r.apply(n,t)}}(t[r],t)})}p.extend(F[r],i)},y.CollectionMixin={query:function(r,n){return y.find(this.toJSON(),r,n)},aggregate:function(r){var n=[this.toJSON(),r];return y.aggregate.apply(null,n)}};var _={$group:function(r,n){var t=n[d.key],e=c(r,function(r){return l(r,t,t)}),i=[];return n=p.omit(n,d.key),p.each(e.keys,function(r,t){var u={};p.isUndefined(r)||(u[d.key]=r);for(var o in n)p.has(n,o)&&(u[o]=f(e.groups[t],o,n[o]));i.push(u)}),i},$match:function(r,n){return new y.Query(n).find(r).all()},$project:function(r,n){if(p.isEmpty(n))return r;var t=[],e=p.keys(n),i=!1;if(p.contains(e,d.key)){var o=n[d.key];0!==o&&o!==!1||(e=p.without(e,d.key),p.isEmpty(e)&&(i=!0))}else e.push(d.key);for(var s=0;s<r.length;s++){var c=r[s],f={},h=!1,y=!1,g=[];i&&g.push(d.key),p.each(e,function(r){var t,e=n[r];if(r!==d.key&&0===e&&(y=!0),r===d.key&&p.isEmpty(e))t=c[r];else if(p.isString(e))t=l(c,e,r);else if(1===e||e===!0)t=u(c,r);else if(p.isObject(e)){var i=p.keys(e);if(i=i.length>1?!1:i[0],i!==!1&&p.contains(a(B),i)){var o=x[i](c,e[i],r);p.isUndefined(o)||(t=o),"$slice"==i&&(h=!0)}else t=l(c,e,r)}else g.push(r);p.isUndefined(t)||(f[r]=t)}),(h||y||i)&&(f=p.defaults(f,p.omit(c,g))),t.push(f)}return t},$limit:function(r,n){return p.first(r,n)},$skip:function(r,n){return p.rest(r,n)},$unwind:function(r,n){for(var t=[],e=n.substr(1),i=0;i<r.length;i++){var o=r[i],s=u(o,e);if(!p.isArray(s))throw new Error("Target field '"+e+"' is not of type Array.");p.each(s,function(r){var n=p.clone(o);n[e]=r,t.push(n)})}return t},$sort:function(r,n){if(!p.isEmpty(n)&&p.isObject(n)){var t=p.keys(n);t.reverse().forEach(function(t){var e=[],i=p.groupBy(r,function(r){var n=o(r,t);return e.push(n),n});e=p.sortBy(p.uniq(e),function(r){return r}),-1===n[t]&&e.reverse(),r=[],p.each(e,function(n){Array.prototype.push.apply(r,i[n])})})}return r}},E={},k={$and:function(r,n){if(!p.isArray(n))throw new Error("Invalid expression for $and criteria");var t=[];return p.each(n,function(r){t.push(new y.Query(r))}),{test:function(r){for(var n=0;n<t.length;n++)if(!t[n].test(r))return!1;return!0}}},$or:function(r,n){if(!p.isArray(n))throw new Error("Invalid expression for $or criteria");var t=[];return p.each(n,function(r){t.push(new y.Query(r))}),{test:function(r){for(var n=0;n<t.length;n++)if(t[n].test(r))return!0;return!1}}},$nor:function(r,n){if(!p.isArray(n))throw new Error("Invalid expression for $nor criteria");var t=this.$or("$or",n);return{test:function(r){return!t.test(r)}}},$not:function(r,n){var t={};t[r]=i(n);var e=new y.Query(t);return{test:function(r){return!e.test(r)}}},$where:function(r,n){return p.isFunction(n)||(n=new Function("return "+n+";")),{test:function(r){return n.call(r)===!0}}}};p.extend(E,k);var A={$eq:function(r,t){return r=p.flatten([r]),r=p.find(r,function(r){return p.isEqual(r,t)}),r!==n},$ne:function(r,n){return!this.$eq(r,n)},$in:function(r,n){return r=p.isArray(r)?r:[r],p.intersection(r,n).length>0},$nin:function(r,n){return p.isUndefined(r)||!this.$in(r,n)},$lt:function(r,t){return r=p.isArray(r)?r:[r],r=p.find(r,function(r){return t>r}),r!==n},$lte:function(r,t){return r=p.isArray(r)?r:[r],r=p.find(r,function(r){return t>=r}),r!==n},$gt:function(r,t){return r=p.isArray(r)?r:[r],r=p.find(r,function(r){return r>t}),r!==n},$gte:function(r,t){return r=p.isArray(r)?r:[r],r=p.find(r,function(r){return r>=t}),r!==n},$mod:function(r,t){return r=p.isArray(r)?r:[r],r=p.find(r,function(r){return p.isNumber(r)&&p.isArray(t)&&2===t.length&&r%t[0]===t[1]}),r!==n},$regex:function(r,t){return r=p.isArray(r)?r:[r],r=p.find(r,function(r){return p.isString(r)&&p.isRegExp(t)&&!!r.match(t)}),r!==n},$exists:function(r,n){return n===!1&&p.isUndefined(r)||n===!0&&!p.isUndefined(r)},$all:function(r,n){var t=this,e=!1;if(p.isArray(r)&&p.isArray(n))for(var i=0;i<n.length;i++){if(!p.isObject(n[i])||!p.contains(p.keys(n[i]),"$elemMatch"))return p.intersection(n,r).length===n.length;e=e||t.$elemMatch(r,n[i].$elemMatch)}return e},$size:function(r,n){return p.isArray(r)&&p.isNumber(n)&&r.length===n},$elemMatch:function(r,n){if(p.isArray(r)&&!p.isEmpty(r))for(var t=new y.Query(n),e=0;e<r.length;e++)if(t.test(r[e]))return!0;return!1},$type:function(r,n){switch(n){case 1:return p.isNumeric(r)&&-1!==(r+"").indexOf(".");case 2:case 5:return p.isString(r);case 3:return p.isObject(r);case 4:return p.isArray(r);case 8:return p.isBoolean(r);case 9:return p.isDate(r);case 10:return p.isNull(r);case 11:return p.isRegExp(r);case 16:return p.isNumeric(r)&&2147483647>=r&&-1===(r+"").indexOf(".");case 18:return p.isNumeric(r)&&r>2147483647&&0x8000000000000000>=r&&-1===(r+"").indexOf(".");default:return!1}}};p.each(p.keys(A),function(r){E[r]=function(r,n){return function(t,e){return{test:function(i){var u=o(i,t);return r.call(n,u,e)}}}}(A[r],A)});var x={$:function(r,n,t){throw new Error("$ not implemented")},$elemMatch:function(r,t,e){var i=o(r,e),u=new y.Query(t);if(p.isUndefined(i)||!p.isArray(i))return n;for(var s=0;s<i.length;s++)if(u.test(i[s]))return[i[s]];return n},$slice:function(r,n,t){var e=o(r,t);if(!p.isArray(e))return e;if(p.isArray(n)){var i=n[0]<0?e.length+n[0]:n,u=i+n[1];n=[i,u]}else{if(!p.isNumber(n))throw new Error("Invalid type for $slice operator");n=0>n?[n]:[0,n]}return Array.prototype.slice.apply(e,n)}},O={$addToSet:function(r,n){var t=p.map(r,function(r){return l(r,n,null)});return p.uniq(t)},$sum:function(r,n){return p.isArray(r)?p.isNumber(n)?r.length*n:p.reduce(r,function(r,t){var e=l(t,n,null);return p.isNumber(e)?r+e:r},0):0},$max:function(r,n){var t=p.max(r,function(r){return l(r,n,null)});return l(t,n,null)},$min:function(r,n){var t=p.min(r,function(r){return l(r,n,null)});return l(t,n,null)},$avg:function(r,n){return this.$sum(r,n)/(r.length||1)},$push:function(r,n){return p.map(r,function(r){return l(r,n,null)})},$first:function(r,t){return r.length>0?l(r[0],t):n},$last:function(r,t){return r.length>0?l(r[r.length-1],t):n}},b={$add:function(r,n){var t=l(r,n,null);return p.reduce(t,function(r,n){return r+n},0)},$subtract:function(r,n){var t=l(r,n,null);return t[0]-t[1]},$divide:function(r,n){var t=l(r,n,null);return t[0]/t[1]},$multiply:function(r,n){var t=l(r,n,null);return p.reduce(t,function(r,n){return r*n},1)},$mod:function(r,n){var t=l(r,n,null);return t[0]%t[1]}},j={$concat:function(r,t){var e=l(r,t,null);return p.contains(e,null)||p.contains(e,n)?null:e.join("")},$strcasecmp:function(r,n){var t=l(r,n,null);return t[0]=p.isEmpty(t[0])?"":t[0].toUpperCase(),t[1]=p.isEmpty(t[1])?"":t[1].toUpperCase(),t[0]>t[1]?1:t[0]<t[1]?-1:0},$substr:function(r,n){var t=l(r,n,null);return p.isString(t[0])?t[1]<0?"":t[2]<0?t[0].substr(t[1]):t[0].substr(t[1],t[2]):""},$toLower:function(r,n){var t=l(r,n,null);return p.isEmpty(t)?"":t.toLowerCase()},$toUpper:function(r,n){var t=l(r,n,null);return p.isEmpty(t)?"":t.toUpperCase()}},q={$dayOfYear:function(r,t){var e=l(r,t,null);if(p.isDate(e)){var i=new Date(e.getFullYear(),0,0),u=e-i,o=864e5;return Math.round(u/o)}return n},$dayOfMonth:function(r,t){var e=l(r,t,null);return p.isDate(e)?e.getDate():n},$dayOfWeek:function(r,t){var e=l(r,t,null);return p.isDate(e)?e.getDay()+1:n},$year:function(r,t){var e=l(r,t,null);return p.isDate(e)?e.getFullYear():n},$month:function(r,t){var e=l(r,t,null);return p.isDate(e)?e.getMonth()+1:n},$week:function(r,n){var t=l(r,n,null);t=new Date(+t),t.setHours(0,0,0),t.setDate(t.getDate()+4-(t.getDay()||7));var e=new Date(t.getFullYear(),0,1);return Math.floor(((t-e)/864e5+1)/7)},$hour:function(r,t){var e=l(r,t,null);return p.isDate(e)?e.getHours():n},$minute:function(r,t){var e=l(r,t,null);return p.isDate(e)?e.getMinutes():n},$second:function(r,t){var e=l(r,t,null);return p.isDate(e)?e.getSeconds():n},$millisecond:function(r,t){var e=l(r,t,null);return p.isDate(e)?e.getMilliseconds():n},$dateToString:function(r,n){for(var t=n.format,e=l(r,n.date,null),i=t.match(/(%%|%Y|%m|%d|%H|%M|%S|%L|%j|%w|%U)/g),u=0,o=i.length;o>u;u++){var a=J[i[u]],c=a;if(p.isArray(a)){var f=this[a[0]],h=a[1];c=s(f.call(this,r,e),h)}t=t.replace(i[u],c)}return t}},S={$setEquals:function(r,n){var t=l(r,n,null),e=p.uniq(t[0]),i=p.uniq(t[1]);return e.length!==i.length?!1:0==p.difference(e,i).length},$setIntersection:function(r,n){var t=l(r,n,null);return p.intersection(t[0],t[1])},$setDifference:function(r,n){var t=l(r,n,null);return p.difference(t[0],t[1])},$setUnion:function(r,n){var t=l(r,n,null);return p.union(t[0],t[1])},$setIsSubset:function(r,n){var t=l(r,n,null);return p.intersection(t[0],t[1]).length===t[0].length},$anyElementTrue:function(r,n){for(var t=l(r,n,null)[0],e=0;e<t.length;e++)if(t[e])return!0;return!1},$allElementsTrue:function(r,n){for(var t=l(r,n,null)[0],e=0;e<t.length;e++)if(!t[e])return!1;return!0}},M={$cond:function(r,n){var t,e,i;if(p.isArray(n)){if(3!=n.length)throw new Error("Invalid arguments for $cond operator");t=n[0],e=n[1],i=n[2]}else p.isObject(n)&&(t=n["if"],e=n.then,i=n["else"]);var u=l(r,t,null);return u?l(r,e,null):l(r,i,null)},$ifNull:function(r,t){if(!p.isArray(t)||2!=t.length)throw new Error("Invalid arguments for $ifNull operator");var e=l(r,t,null);return null===e[0]||e[0]===n?e[1]:e[0]}},N={$cmp:function(r,n){var t=l(r,n,null);return t[0]>t[1]?1:t[0]<t[1]?-1:0}};p.each(["$eq","$ne","$gt","$gte","$lt","$lte"],function(r){N[r]=function(n,t){var e=l(n,t,null);return A[r](e[0],e[1])}});var I={$size:function(r,t){var e=l(r,t,null);return p.isArray(e)?e.length:n}},D={$literal:function(r,n){return n}},U={$map:function(r,n){var t=l(r,n.input,null);if(!p.isArray(t))throw new Error("Input expression for $map must resolve to an array");var e=n.as,i=n["in"],u="$"+e,o=r[u];return p.map(t,function(n){r[u]=n;var t=l(r,i,null);return p.isUndefined(o)?delete r[u]:r[u]=o,t})},$let:function(r,n){var t=n.vars,e=n["in"],i={},u=p.keys(t);p.each(u,function(n){var e=l(r,t[n],null),u="$"+n;i[u]=r[u],r[u]=e});var o=l(r,e,null);return p.each(u,function(n){var t="$"+n;p.isUndefined(i[t])?delete r[t]:r[t]=i[t]}),o}},Q={$and:function(r,n){var t=l(r,n,null);return p.every(t)},$or:function(r,n){var t=l(r,n,null);return p.some(t)},$not:function(r,n){return!l(r,n[0],null)}},C=p.extend({},I,b,Q,N,M,q,D,S,j,U),R=y.OP_QUERY="query",P=y.OP_GROUP="group",T=y.OP_AGGREGATE="aggregate",Y=y.OP_PIPELINE="pipeline",B=y.OP_PROJECTION="projection",F={aggregate:C,group:O,pipeline:_,projection:x,query:E},J={"%Y":["$year",4],"%m":["$month",2],"%d":["$dayOfMonth",2],"%H":["$hour",2],"%M":["$minute",2],"%S":["$second",2],"%L":["$millisecond",3],"%j":["$dayOfYear",3],"%w":["$dayOfWeek",1],"%U":["$week",2],"%%":"%"}}(this);
!function(r,n){"use strict";function t(r){for(var n=0;n<$.length;n++)if($[n](r))return!0;return!1}function e(r){return t(r)||!y.contains(m,r.constructor.name)}function i(r){if(e(r))return y.isRegExp(r)?{$regex:r}:{$eq:r};if(y.isObject(r)){var n=y.keys(r),t=0===y.intersection(a(J),n).length;if(t)return{$eq:r};if(y.contains(n,"$regex")){var i=r.$regex,u=r.$options||"",o="";y.isString(i)&&(o+=i.ignoreCase||u.indexOf("i")>=0?"i":"",o+=i.multiline||u.indexOf("m")>=0?"m":"",o+=i.global||u.indexOf("g")>=0?"g":"",i=new RegExp(i,o)),r.$regex=i,delete r.$options}}return r}function u(r,n){return y.result(r,n)}function o(r,t){if(!t)return n;for(var e,i=t.split("."),s=r,a=0;a<i.length;a++){if(e=null===i[a].match(/^\d+$/),e&&y.isArray(s)){var c=[];y.each(s,function(r){c.push(o(r,i[a]))}),s=c}else s=u(s,i[a]);if(s===n)break}return s}function s(r,n){return new Array(Math.max(n-String(r).length+1,0)).join("0")+r}function a(r){return y.keys(L[r])}function c(r,n){var t={keys:[],groups:[]},e={};if(y.each(r,function(r){var i=n(r),u=l(i),o=-1;y.isUndefined(e[u])&&(o=t.keys.length,e[u]=o,t.keys.push(i),t.groups.push([])),o=e[u],t.groups[o].push(r)}),t.keys.length!==t.groups.length)throw new Error("assert groupBy(): keys.length !== groups.length");return t}function f(r){if(y.isNull(r))return"null";if(y.isUndefined(r))return"undef";var n=r.constructor.name;switch(n){case"Boolean":return"b|"+r.toString();case"String":return"s|"+r.toString();case"RegExp":return"r|"+r.toString();case"Number":return"n|"+r.toString();case"Date":return"d|"+r.toISOString();case"Array":return"a|"+JSON.stringify(y.map(r,function(r){return f(r)}));case"Object":return"o|"+JSON.stringify(y.mapObject(r,function(r){return f(r)}));default:return n+"|"+JSON.stringify(y.mapObject(r,function(r){return f(r)}))}}function l(r){var n,t,e,i=0,u=f(r);if(0===u.length)return i;for(n=0,e=u.length;e>n;n++)t=u.charCodeAt(n),i=(i<<5)-i+t,i|=0;return i.toString()}function h(r,t,e){if(y.contains(a(T),t))return S[t](r,e);if(y.isObject(e)){var i={};for(var u in e)if(y.has(e,u)&&(i[u]=h(r,u,e[u]),y.contains(a(T),u))){if(i=i[u],y.keys(e).length>1)throw new Error("Invalid $group expression '"+JSON.stringify(e)+"'");break}return i}return n}function p(r,n,t){if(y.contains(a(Y),t))return P[t](r,n);if(y.isString(n)&&n.length>0&&"$"===n[0])return o(r,n.slice(1));var i;if(e(n))return n;if(y.isArray(n))i=y.map(n,function(n){return p(r,n,null)});else if(y.isObject(n)){i={};for(var u in n)if(y.has(n,u)&&(i[u]=p(r,n[u],u),y.contains(a(Y),u))){if(i=i[u],y.keys(n).length>1)throw new Error("Invalid aggregation expression '"+JSON.stringify(n)+"'");break}}return i}var g,y,v={};v.VERSION="0.6.5",null!=r&&(g=r.Mingo),v.noConflict=function(){return r.Mingo=g,v};var d="undefined"!=typeof module&&"undefined"!=typeof require;d?("undefined"!=typeof module&&(module.exports=v),y=require("underscore")):(r.Mingo=v,y=r._);var $=[y.isString,y.isBoolean,y.isNumber,y.isDate,y.isNull,y.isRegExp,y.isUndefined],m=["Object","Array"],w={key:"_id"};if(v.setup=function(r){y.extend(w,r||{})},v.Query=function(r,n){return this instanceof v.Query?(this._criteria=r,this._projection=n,this._compiled=[],void this._compile()):new v.Query(r,n)},v.Query.prototype={_compile:function(){if(!y.isEmpty(this._criteria)){if(y.isArray(this._criteria)||y.isFunction(this._criteria)||!y.isObject(this._criteria))throw new Error("Invalid type for criteria");for(var r in this._criteria)if(y.has(this._criteria,r)){var n=this._criteria[r];if(y.contains(["$and","$or","$nor","$where"],r))this._processOperator(r,r,n);else{n=i(n);for(var t in n)y.has(n,t)&&this._processOperator(r,t,n[t])}}}},_processOperator:function(r,n,t){if(!y.contains(a(J),n))throw new Error("Invalid query operator '"+n+"' detected");this._compiled.push(A[n](r,t))},test:function(r){for(var n=0;n<this._compiled.length;n++)if(!this._compiled[n].test(r))return!1;return!0},find:function(r,n){return new v.Cursor(r,this,n)},remove:function(r){for(var n=[],t=0;t<r.length;t++)this.test(r[t])||n.push(r[t]);return n}},d){var _=require("stream").Transform,E=require("util");v.Query.prototype.stream=function(r){return new v.Stream(this,r)},v.Stream=function(r,n){return this instanceof v.Stream?(n=n||{},y.extend(n,{objectMode:!0}),_.call(this,n),void(this._query=r)):new v.Stream(r,n)},E.inherits(v.Stream,_),v.Stream.prototype._transform=function(r,n,t){if(y.isObject(r)&&this._query.test(r))if(y.isEmpty(this._query._projection))this.push(r);else{var e=new v.Cursor([r],this._query);e.hasNext()&&this.push(e.next())}t()}}v.Cursor=function(r,n,t){return this instanceof v.Cursor?(this._query=n,this._collection=r,this._projection=t||n._projection,this._operators={},this._result=!1,void(this._position=0)):new v.Cursor(r,n,t)},v.Cursor.prototype={_fetch:function(){var r=this;if(this._result!==!1)return this._result;if(y.isObject(this._projection)&&y.extend(this._operators,{$project:this._projection}),!y.isArray(this._collection))throw new Error("Input collection is not of valid type. Must be an Array.");this._result=y.filter(this._collection,this._query.test,this._query);var n=[];if(y.each(["$sort","$skip","$limit","$project"],function(t){y.has(r._operators,t)&&n.push(y.pick(r._operators,t))}),n.length>0){var t=new v.Aggregator(n);this._result=t.run(this._result,this._query)}return this._result},all:function(){return this._fetch()},first:function(){return this.count()>0?this._fetch()[0]:null},last:function(){return this.count()>0?this._fetch()[this.count()-1]:null},count:function(){return this._fetch().length},skip:function(r){return y.extend(this._operators,{$skip:r}),this},limit:function(r){return y.extend(this._operators,{$limit:r}),this},sort:function(r){return y.extend(this._operators,{$sort:r}),this},next:function(){return this.hasNext()?this._fetch()[this._position++]:null},hasNext:function(){return this.count()>this._position},max:function(r){return S.$max(this._fetch(),r)},min:function(r){return S.$min(this._fetch(),r)},map:function(r){return y.map(this._fetch(),r)},forEach:function(r){y.each(this._fetch(),r)}},v.Aggregator=function(r){return this instanceof v.Aggregator?void(this._operators=r):new v.Aggregator(r)},v.Aggregator.prototype={run:function(r,n){if(!y.isEmpty(this._operators))for(var t=0;t<this._operators.length;t++){var e=this._operators[t],i=y.keys(e);if(1!=i.length||!y.contains(a(B),i[0]))throw new Error("Invalid aggregation operator '"+i+"'");i=i[0],r=n instanceof v.Query?k[i].call(n,r,e[i]):k[i](r,e[i])}return r}},v.find=function(r,n,t){return new v.Query(n).find(r,t)},v.remove=function(r,n){return new v.Query(n).remove(r)},v.aggregate=function(r,n){if(!y.isArray(n))throw new Error("Aggregation pipeline must be an array");return new v.Aggregator(n).run(r)},v.addOperators=function(r,n){var t=n({resolve:o,computeValue:p,ops:a,key:function(){return w.key}});if(!y.contains([Y,T,B,F,J],r))throw new Error("Could not identify type '"+r+"'");var e=a(r);y.each(y.keys(t),function(n){if(!/^\$\w+$/.test(n))throw new Error("Invalid operator name '"+n+"'");if(y.contains(e,n))throw new Error("Operator "+n+" is already defined for "+r+" operators")});var i={};switch(r){case J:y.each(y.keys(t),function(r){i[r]=function(n,t){return function(e,i){return{test:function(u){var s=o(u,e),a=n.call(t,e,s,i);if(y.isBoolean(a))return a;if(a instanceof v.Query)return a.test(u);throw new Error("Invalid return type for '"+r+"'. Must return a Boolean or Mingo.Query")}}}}(t[r],t)});break;case F:y.each(y.keys(t),function(r){i[r]=function(r,n){return function(t,e,i){var u=o(t,i);return r.call(n,i,u,e)}}(t[r],t)});break;default:y.each(y.keys(t),function(r){i[r]=function(r,n){return function(){var t=Array.prototype.slice.call(arguments);return r.apply(n,t)}}(t[r],t)})}y.extend(L[r],i)},v.CollectionMixin={query:function(r,n){return v.find(this.toJSON(),r,n)},aggregate:function(r){var n=[this.toJSON(),r];return v.aggregate.apply(null,n)}};var k={$group:function(r,n){var t=n[w.key],e=c(r,function(r){return p(r,t,t)}),i=[];return n=y.omit(n,w.key),y.each(e.keys,function(r,t){var u={};y.isUndefined(r)||(u[w.key]=r);for(var o in n)y.has(n,o)&&(u[o]=h(e.groups[t],o,n[o]));i.push(u)}),i},$match:function(r,n){return new v.Query(n).find(r).all()},$project:function(r,n){if(y.isEmpty(n))return r;var t=[],e=y.keys(n),i=!1;if(y.contains(e,w.key)){var o=n[w.key];0!==o&&o!==!1||(e=y.without(e,w.key),y.isEmpty(e)&&(i=!0))}else e.push(w.key);for(var s=0;s<r.length;s++){var c=r[s],f={},l=!1,h=!1,g=[];i&&g.push(w.key),y.each(e,function(r){var t,e=n[r];if(r!==w.key&&0===e&&(h=!0),r===w.key&&y.isEmpty(e))t=c[r];else if(y.isString(e))t=p(c,e,r);else if(1===e||e===!0)t=u(c,r);else if(y.isObject(e)){var i=y.keys(e);if(i=i.length>1?!1:i[0],i!==!1&&y.contains(a(F),i)){var o=b[i](c,e[i],r);y.isUndefined(o)||(t=o),"$slice"==i&&(l=!0)}else t=p(c,e,r)}else g.push(r);y.isUndefined(t)||(f[r]=t)}),(l||h||i)&&(f=y.defaults(f,y.omit(c,g))),t.push(f)}return t},$limit:function(r,n){return y.first(r,n)},$skip:function(r,n){return y.rest(r,n)},$unwind:function(r,n){for(var t=[],e=n.substr(1),i=0;i<r.length;i++){var o=r[i],s=u(o,e);if(!y.isArray(s))throw new Error("Target field '"+e+"' is not of type Array.");y.each(s,function(r){var n=y.clone(o);n[e]=r,t.push(n)})}return t},$sort:function(r,n){if(!y.isEmpty(n)&&y.isObject(n)){var t=y.keys(n);t.reverse().forEach(function(t){var e=c(r,function(r){return o(r,t)}),i={},u=function(r){return i[l(r)]},s=y.sortBy(e.keys,function(r,n){return i[l(r)]=n,r});-1===n[t]&&s.reverse(),r=[],y.each(s,function(n){Array.prototype.push.apply(r,e.groups[u(n)])})})}return r}},A={},O={$and:function(r,n){if(!y.isArray(n))throw new Error("Invalid expression for $and criteria");var t=[];return y.each(n,function(r){t.push(new v.Query(r))}),{test:function(r){for(var n=0;n<t.length;n++)if(!t[n].test(r))return!1;return!0}}},$or:function(r,n){if(!y.isArray(n))throw new Error("Invalid expression for $or criteria");var t=[];return y.each(n,function(r){t.push(new v.Query(r))}),{test:function(r){for(var n=0;n<t.length;n++)if(t[n].test(r))return!0;return!1}}},$nor:function(r,n){if(!y.isArray(n))throw new Error("Invalid expression for $nor criteria");var t=this.$or("$or",n);return{test:function(r){return!t.test(r)}}},$not:function(r,n){var t={};t[r]=i(n);var e=new v.Query(t);return{test:function(r){return!e.test(r)}}},$where:function(r,n){return y.isFunction(n)||(n=new Function("return "+n+";")),{test:function(r){return n.call(r)===!0}}}};y.extend(A,O);var x={$eq:function(r,t){return r=y.flatten([r]),r=y.find(r,function(r){return y.isEqual(r,t)}),r!==n},$ne:function(r,n){return!this.$eq(r,n)},$in:function(r,n){return r=y.isArray(r)?r:[r],y.intersection(r,n).length>0},$nin:function(r,n){return y.isUndefined(r)||!this.$in(r,n)},$lt:function(r,t){return r=y.isArray(r)?r:[r],r=y.find(r,function(r){return t>r}),r!==n},$lte:function(r,t){return r=y.isArray(r)?r:[r],r=y.find(r,function(r){return t>=r}),r!==n},$gt:function(r,t){return r=y.isArray(r)?r:[r],r=y.find(r,function(r){return r>t}),r!==n},$gte:function(r,t){return r=y.isArray(r)?r:[r],r=y.find(r,function(r){return r>=t}),r!==n},$mod:function(r,t){return r=y.isArray(r)?r:[r],r=y.find(r,function(r){return y.isNumber(r)&&y.isArray(t)&&2===t.length&&r%t[0]===t[1]}),r!==n},$regex:function(r,t){return r=y.isArray(r)?r:[r],r=y.find(r,function(r){return y.isString(r)&&y.isRegExp(t)&&!!r.match(t)}),r!==n},$exists:function(r,n){return n===!1&&y.isUndefined(r)||n===!0&&!y.isUndefined(r)},$all:function(r,n){var t=this,e=!1;if(y.isArray(r)&&y.isArray(n))for(var i=0;i<n.length;i++){if(!y.isObject(n[i])||!y.contains(y.keys(n[i]),"$elemMatch"))return y.intersection(n,r).length===n.length;e=e||t.$elemMatch(r,n[i].$elemMatch)}return e},$size:function(r,n){return y.isArray(r)&&y.isNumber(n)&&r.length===n},$elemMatch:function(r,n){if(y.isArray(r)&&!y.isEmpty(r))for(var t=new v.Query(n),e=0;e<r.length;e++)if(t.test(r[e]))return!0;return!1},$type:function(r,n){switch(n){case 1:return y.isNumeric(r)&&-1!==(r+"").indexOf(".");case 2:case 5:return y.isString(r);case 3:return y.isObject(r);case 4:return y.isArray(r);case 8:return y.isBoolean(r);case 9:return y.isDate(r);case 10:return y.isNull(r);case 11:return y.isRegExp(r);case 16:return y.isNumeric(r)&&2147483647>=r&&-1===(r+"").indexOf(".");case 18:return y.isNumeric(r)&&r>2147483647&&0x8000000000000000>=r&&-1===(r+"").indexOf(".");default:return!1}}};y.each(y.keys(x),function(r){A[r]=function(r,n){return function(t,e){return{test:function(i){var u=o(i,t);return r.call(n,u,e)}}}}(x[r],x)});var b={$:function(r,n,t){throw new Error("$ not implemented")},$elemMatch:function(r,t,e){var i=o(r,e),u=new v.Query(t);if(y.isUndefined(i)||!y.isArray(i))return n;for(var s=0;s<i.length;s++)if(u.test(i[s]))return[i[s]];return n},$slice:function(r,n,t){var e=o(r,t);if(!y.isArray(e))return e;if(y.isArray(n)){var i=n[0]<0?e.length+n[0]:n,u=i+n[1];n=[i,u]}else{if(!y.isNumber(n))throw new Error("Invalid type for $slice operator");n=0>n?[n]:[0,n]}return Array.prototype.slice.apply(e,n)}},S={$addToSet:function(r,n){var t=y.map(r,function(r){return p(r,n,null)});return y.uniq(t)},$sum:function(r,n){return y.isArray(r)?y.isNumber(n)?r.length*n:y.reduce(r,function(r,t){var e=p(t,n,null);return y.isNumber(e)?r+e:r},0):0},$max:function(r,n){var t=y.max(r,function(r){return p(r,n,null)});return p(t,n,null)},$min:function(r,n){var t=y.min(r,function(r){return p(r,n,null)});return p(t,n,null)},$avg:function(r,n){return this.$sum(r,n)/(r.length||1)},$push:function(r,n){return y.map(r,function(r){return p(r,n,null)})},$first:function(r,t){return r.length>0?p(r[0],t):n},$last:function(r,t){return r.length>0?p(r[r.length-1],t):n}},j={$add:function(r,n){var t=p(r,n,null);return y.reduce(t,function(r,n){return r+n},0)},$subtract:function(r,n){var t=p(r,n,null);return t[0]-t[1]},$divide:function(r,n){var t=p(r,n,null);return t[0]/t[1]},$multiply:function(r,n){var t=p(r,n,null);return y.reduce(t,function(r,n){return r*n},1)},$mod:function(r,n){var t=p(r,n,null);return t[0]%t[1]}},N={$concat:function(r,t){var e=p(r,t,null);return y.contains(e,null)||y.contains(e,n)?null:e.join("")},$strcasecmp:function(r,n){var t=p(r,n,null);return t[0]=y.isEmpty(t[0])?"":t[0].toUpperCase(),t[1]=y.isEmpty(t[1])?"":t[1].toUpperCase(),t[0]>t[1]?1:t[0]<t[1]?-1:0},$substr:function(r,n){var t=p(r,n,null);return y.isString(t[0])?t[1]<0?"":t[2]<0?t[0].substr(t[1]):t[0].substr(t[1],t[2]):""},$toLower:function(r,n){var t=p(r,n,null);return y.isEmpty(t)?"":t.toLowerCase()},$toUpper:function(r,n){var t=p(r,n,null);return y.isEmpty(t)?"":t.toUpperCase()}},q={$dayOfYear:function(r,t){var e=p(r,t,null);if(y.isDate(e)){var i=new Date(e.getFullYear(),0,0),u=e-i,o=864e5;return Math.round(u/o)}return n},$dayOfMonth:function(r,t){var e=p(r,t,null);return y.isDate(e)?e.getDate():n},$dayOfWeek:function(r,t){var e=p(r,t,null);return y.isDate(e)?e.getDay()+1:n},$year:function(r,t){var e=p(r,t,null);return y.isDate(e)?e.getFullYear():n},$month:function(r,t){var e=p(r,t,null);return y.isDate(e)?e.getMonth()+1:n},$week:function(r,n){var t=p(r,n,null);t=new Date(+t),t.setHours(0,0,0),t.setDate(t.getDate()+4-(t.getDay()||7));var e=new Date(t.getFullYear(),0,1);return Math.floor(((t-e)/864e5+1)/7)},$hour:function(r,t){var e=p(r,t,null);return y.isDate(e)?e.getHours():n},$minute:function(r,t){var e=p(r,t,null);return y.isDate(e)?e.getMinutes():n},$second:function(r,t){var e=p(r,t,null);return y.isDate(e)?e.getSeconds():n},$millisecond:function(r,t){var e=p(r,t,null);return y.isDate(e)?e.getMilliseconds():n},$dateToString:function(r,n){for(var t=n.format,e=p(r,n.date,null),i=t.match(/(%%|%Y|%m|%d|%H|%M|%S|%L|%j|%w|%U)/g),u=0,o=i.length;o>u;u++){var a=G[i[u]],c=a;if(y.isArray(a)){var f=this[a[0]],l=a[1];c=s(f.call(this,r,e),l)}t=t.replace(i[u],c)}return t}},M={$setEquals:function(r,n){var t=p(r,n,null),e=y.uniq(t[0]),i=y.uniq(t[1]);return e.length!==i.length?!1:0==y.difference(e,i).length},$setIntersection:function(r,n){var t=p(r,n,null);return y.intersection(t[0],t[1])},$setDifference:function(r,n){var t=p(r,n,null);return y.difference(t[0],t[1])},$setUnion:function(r,n){var t=p(r,n,null);return y.union(t[0],t[1])},$setIsSubset:function(r,n){var t=p(r,n,null);return y.intersection(t[0],t[1]).length===t[0].length},$anyElementTrue:function(r,n){for(var t=p(r,n,null)[0],e=0;e<t.length;e++)if(t[e])return!0;return!1},$allElementsTrue:function(r,n){for(var t=p(r,n,null)[0],e=0;e<t.length;e++)if(!t[e])return!1;return!0}},I={$cond:function(r,n){var t,e,i;if(y.isArray(n)){if(3!=n.length)throw new Error("Invalid arguments for $cond operator");t=n[0],e=n[1],i=n[2]}else y.isObject(n)&&(t=n["if"],e=n.then,i=n["else"]);var u=p(r,t,null);return u?p(r,e,null):p(r,i,null)},$ifNull:function(r,t){if(!y.isArray(t)||2!=t.length)throw new Error("Invalid arguments for $ifNull operator");var e=p(r,t,null);return null===e[0]||e[0]===n?e[1]:e[0]}},D={$cmp:function(r,n){var t=p(r,n,null);return t[0]>t[1]?1:t[0]<t[1]?-1:0}};y.each(["$eq","$ne","$gt","$gte","$lt","$lte"],function(r){D[r]=function(n,t){var e=p(n,t,null);return x[r](e[0],e[1])}});var U={$size:function(r,t){var e=p(r,t,null);return y.isArray(e)?e.length:n}},Q={$literal:function(r,n){return n}},C={$map:function(r,n){var t=p(r,n.input,null);if(!y.isArray(t))throw new Error("Input expression for $map must resolve to an array");var e=n.as,i=n["in"],u="$"+e,o=r[u];return y.map(t,function(n){r[u]=n;var t=p(r,i,null);return y.isUndefined(o)?delete r[u]:r[u]=o,t})},$let:function(r,n){var t=n.vars,e=n["in"],i={},u=y.keys(t);y.each(u,function(n){var e=p(r,t[n],null),u="$"+n;i[u]=r[u],r[u]=e});var o=p(r,e,null);return y.each(u,function(n){var t="$"+n;y.isUndefined(i[t])?delete r[t]:r[t]=i[t]}),o}},R={$and:function(r,n){var t=p(r,n,null);return y.every(t)},$or:function(r,n){var t=p(r,n,null);return y.some(t)},$not:function(r,n){return!p(r,n[0],null)}},P=y.extend({},U,j,R,D,I,q,Q,M,N,C),J=v.OP_QUERY="query",T=v.OP_GROUP="group",Y=v.OP_AGGREGATE="aggregate",B=v.OP_PIPELINE="pipeline",F=v.OP_PROJECTION="projection",L={aggregate:P,group:S,pipeline:k,projection:b,query:A},G={"%Y":["$year",4],"%m":["$month",2],"%d":["$dayOfMonth",2],"%H":["$hour",2],"%M":["$minute",2],"%S":["$second",2],"%L":["$millisecond",3],"%j":["$dayOfYear",3],"%w":["$dayOfWeek",1],"%U":["$week",2],"%%":"%"}}(this);
//# sourceMappingURL=mingo.min.map
{
"name": "mingo",
"version": "0.6.4",
"version": "0.6.5",
"description": "JavaScript implementation of MongoDB query language",

@@ -5,0 +5,0 @@ "main": "mingo.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc