{"_id":"@jsreport/mingo","_rev":"3-a2859e7644d23e9e6715f0ee0281e5b8","name":"@jsreport/mingo","dist-tags":{"latest":"2.4.2"},"versions":{"2.4.1":{"name":"@jsreport/mingo","version":"2.4.1","keywords":["util","mongo","nosql","query","aggregate","filter","group","project","search","transform"],"author":{"name":"Francis Asante","email":"kofrasa@gmail.com"},"license":"MIT","_id":"@jsreport/mingo@2.4.1","maintainers":[{"name":"pofider","email":"jan.blaha@hotmail.com"},{"name":"bjrmatos","email":"bjrmatos@gmail.com"}],"homepage":"https://github.com/kofrasa/mingo#readme","bugs":{"url":"https://github.com/kofrasa/mingo/issues"},"dist":{"shasum":"019ff48079a3ffeff2a5d8f1380386b921a0fc81","tarball":"https://registry.npmjs.org/@jsreport/mingo/-/mingo-2.4.1.tgz","fileCount":9,"integrity":"sha512-6ZXpnsXoLvXf8t1aGhJ3TamVdi3tHfDGlNs5qfaIQfIlUkga6x6juQD+9twO5NHn+PKKct/FQQBScOqC0SsrmA==","signatures":[{"sig":"MEUCICxnUNzehx0mO9IAv4L6YWKURcH9cA1+e6xS+krl2LpJAiEAkWAK7YAXRcmQG3RN/ySnD2uxqBCmgizQxI/QOzFuyG0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":360378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdw0ovCRA9TVsSAnZWagAAt5MP/06Ksmnj9r8aP33A7AY0\nbOdZiYnfYUMOb0j3MJbbhlkPBNrPxsOdq0audKN6A2jpFjZtkJGQNONUUz72\nWe3DPEREt0eIX9IinpYBeajn8/gbBrWZE4MQf43sJvY4aftFtVuJeC4ZdPva\nmVbav9rqmKkBqqd9kDMKqZEsJIP0rMFauc7yumTWMHrHpBTzJhUXLx3DQgxz\nWfsv4w5eszI57rgq/O8zbrsnRXeBk4ONwWyjiICZSchWoRWLdw0HRGXuJTqr\nJ4mkfzQzSWRu/py8TzH5vCwNavC3KsQXbU++x+otvmrjojwO/VaOWcVidNqJ\n82L2GTQdD88FoCDGxtLe/3RrfLL+AFFeIs8kd6GpNzZfLIiJcljOZqswJ375\nIBwep7KDp0ej/h9Yrm6TVV7elAJh2M0MVl3sSVGS1ze+gsAnyRCWGEwBOPp5\n6ozI4OUpjuiKWiMSN6XEelNTkBi3tBlWloxULgwSoajLGo1u2WDgJRNSVBSo\n3LLMKqgn0SBlNxhkQn3r2u6/hwFMJlVDgWErHJNyDS5fWZ31JtHRatoYTD+2\nuVFNVpeOsNJb0rDsDEUH1OGpdk4T71DMIeinqQ1zWZJak/YuNFfDUoZuW9kd\nf2OZtSE0HT0mi36/DLx9kZiwo/0AEiDW62MMPKs3L8sovUZFNks4BBQ40m4G\nXOxi\r\n=BlZY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/mingo.js","module":"dist/mingo.es6.js","gitHead":"e54b223b116e3a7c95fa251818c93395a0b5aa83","scripts":{"test":"NODE_ENV=test nyc --reporter=lcov --reporter=text tape test/*.js test/**/*.js","build":"npm run build.umd && npm run build.es","clean":"rm -fr dist/*","release":"npm run clean && npm run build && npm test","build.es":"rollup -c config/rollup.es.js","coverage":"nyc report --reporter=text-lcov > coverage.lcov && codecov","build.umd":"rollup -c config/rollup.umd.js","postrelease":"uglifyjs dist/mingo.js --comments '/^!/' --compress --mangle --source-map \"url='dist/mingo.min.js.map'\" --output dist/mingo.min.js"},"_npmUser":{"name":"bjrmatos","email":"bjrmatos@gmail.com"},"repository":{"url":"git+https://github.com/kofrasa/mingo.git","type":"git"},"_npmVersion":"6.12.1","description":"JavaScript implementation of MongoDB query language","directories":{},"_nodeVersion":"8.16.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"nyc":"14.1.1","bson":"4.0.2","tape":"4.11.0","lodash":"4.17.15","rollup":"1.26.3","codecov":"3.6.1","backbone":"1.4.0","istanbul":"0.4.5","benchmark":"2.1.4","uglify-js":"3.6.4","perf_hooks":"0.0.1","@babel/core":"7.7.0","babel-preset-env":"1.7.0","@babel/preset-env":"7.7.1","rollup-plugin-babel":"4.3.3","babel-plugin-istanbul":"5.2.0","rollup-plugin-commonjs":"10.1.0","rollup-plugin-node-resolve":"5.2.0","@babel/plugin-external-helpers":"7.2.0"},"_npmOperationalInternal":{"tmp":"tmp/mingo_2.4.1_1573079599106_0.8627156104676057","host":"s3://npm-registry-packages"}},"2.4.2":{"name":"@jsreport/mingo","version":"2.4.2","description":"JavaScript implementation of MongoDB query language","main":"dist/mingo.js","module":"dist/mingo.es6.js","scripts":{"clean":"rm -fr dist/*","build.umd":"rollup -c config/rollup.umd.js","build.es":"rollup -c config/rollup.es.js","build":"npm run build.umd && npm run build.es","release":"npm run clean && npm run build && npm test","postrelease":"uglifyjs dist/mingo.js --comments '/^!/' --compress --mangle --source-map \"url='dist/mingo.min.js.map'\" --output dist/mingo.min.js","test":"NODE_ENV=test nyc --reporter=lcov --reporter=text tape test/*.js test/**/*.js","coverage":"nyc report --reporter=text-lcov > coverage.lcov && codecov"},"repository":{"type":"git","url":"git+https://github.com/kofrasa/mingo.git"},"devDependencies":{"@babel/core":"7.7.0","@babel/plugin-external-helpers":"7.2.0","@babel/preset-env":"7.7.1","babel-plugin-istanbul":"5.2.0","babel-preset-env":"1.7.0","backbone":"1.4.0","benchmark":"2.1.4","bson":"4.0.2","codecov":"3.6.1","istanbul":"0.4.5","lodash":"4.17.15","nyc":"14.1.1","perf_hooks":"0.0.1","rollup":"1.26.3","rollup-plugin-babel":"4.3.3","rollup-plugin-commonjs":"10.1.0","rollup-plugin-node-resolve":"5.2.0","tape":"4.11.0","uglify-js":"3.6.4"},"keywords":["util","mongo","nosql","query","aggregate","filter","group","project","search","transform"],"author":{"name":"Francis Asante","email":"kofrasa@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/kofrasa/mingo/issues"},"dependencies":{},"_id":"@jsreport/mingo@2.4.2","gitHead":"e87624a5546d5cffbd0a046eb59ac0633aec0289","homepage":"https://github.com/kofrasa/mingo#readme","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-AVTqrTxzl50CJhUfeL1f0X+SwR5ZwCIu4WiwkJYG9I1On/xizOSJ5kIccVbh1CNNzsAgkrJ46W0fQVnlnlYwWA==","shasum":"4655765024e3fceeabb0f2dcb7cdc5addd64a4a7","tarball":"https://registry.npmjs.org/@jsreport/mingo/-/mingo-2.4.2.tgz","fileCount":9,"unpackedSize":360652,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICqqUvzH3yukrRDmvq/0F0ko6jVU7L9V0oePHwSJC4cMAiEA1R4FrPqkcEECgunuDg9Cn8ZLvYyiErJuuPT9vq2pTeM="}]},"_npmUser":{"name":"bjrmatos","email":"bjrmatos@gmail.com"},"directories":{},"maintainers":[{"name":"pofider","email":"jan.blaha@hotmail.com"},{"name":"bjrmatos","email":"bjrmatos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mingo_2.4.2_1785885856560_0.13502058503862302"},"_hasShrinkwrap":false}},"time":{"created":"2019-11-06T22:33:18.939Z","modified":"2026-08-04T23:24:16.941Z","2.4.1":"2019-11-06T22:33:19.311Z","2.4.2":"2026-08-04T23:24:16.726Z"},"bugs":{"url":"https://github.com/kofrasa/mingo/issues"},"author":{"name":"Francis Asante","email":"kofrasa@gmail.com"},"license":"MIT","homepage":"https://github.com/kofrasa/mingo#readme","keywords":["util","mongo","nosql","query","aggregate","filter","group","project","search","transform"],"repository":{"type":"git","url":"git+https://github.com/kofrasa/mingo.git"},"description":"JavaScript implementation of MongoDB query language","maintainers":[{"name":"pofider","email":"jan.blaha@hotmail.com"},{"name":"bjrmatos","email":"bjrmatos@gmail.com"}],"readme":"# mingo\nJavaScript implementation of MongoDB query language\n\n[![version](https://img.shields.io/npm/v/mingo.svg)](https://www.npmjs.org/package/mingo)\n[![build status](https://img.shields.io/travis/kofrasa/mingo.svg)](http://travis-ci.org/kofrasa/mingo)\n[![npm](https://img.shields.io/npm/dm/mingo.svg)](https://www.npmjs.org/package/mingo)\n[![Codecov](https://img.shields.io/codecov/c/github/kofrasa/mingo.svg)](https://codecov.io/gh/kofrasa/mingo)\n[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/kofrasa/mingo.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kofrasa/mingo/context:javascript)\n[![Total Alerts](https://img.shields.io/lgtm/alerts/g/kofrasa/mingo.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kofrasa/mingo/alerts)\n\n## Install\n```$ npm install mingo```\n\n## Features\n- Supports Dot Notation for both _`<array>.<index>`_ and _`<document>.<field>`_ selectors\n- Query and Projection Operators\n  - [Array Operators](https://docs.mongodb.com/manual/reference/operator/query-array/)\n  - [Comparisons Operators](https://docs.mongodb.com/manual/reference/operator/query-comparison/)\n  - [Element Operators](https://docs.mongodb.com/manual/reference/operator/query-element/)\n  - [Evaluation Operators](https://docs.mongodb.com/manual/reference/operator/query-evaluation/)\n  - [Logical Operators](https://docs.mongodb.com/manual/reference/operator/query-logical/)\n- Aggregation Framework Operators\n  - [Pipeline Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/)\n  - [Group Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-group/)\n  - [Projection Operators](https://docs.mongodb.com/manual/reference/operator/projection/)\n  - [Arithmetic Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-arithmetic/)\n  - [Array Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-array/)\n  - [Boolean Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-boolean/)\n  - [Comparisons Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-comparison/)\n  - [Conditional Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-conditional/)\n  - [Date Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-date/)\n  - [Literal Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-literal/)\n  - [Set Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-set/)\n  - [String Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-string/)\n  - [Variable Operators](https://docs.mongodb.com/manual/reference/operator/aggregation-projection/)\n- Support for adding custom operators\n- Match against user-defined types\n- Support for aggregaion variables\n    - [`$$ROOT`,`$$CURRENT`,`$$DESCEND`,`$$PRUNE`,`$$KEEP`,`$$REMOVE`](https://docs.mongodb.com/manual/reference/aggregation-variables/)\n- ES6 module compatible\n- Support integrating with custom collections via mixin\n- Query filter and projection streaming.\n\nFor documentation on using query operators see [mongodb](http://docs.mongodb.org/manual/reference/operator/query/)\n\n## Documentation\n- [API](https://github.com/kofrasa/mingo/wiki/API)\n- [Custom Operators](https://github.com/kofrasa/mingo/wiki/Custom-Operators)\n\n## Usage\nOn the server side\n```js\n// Use as es6 module\nimport mingo from 'mingo'\n\n// or vanilla nodeJS\nvar mingo = require('mingo')\n```\n\nFor the browser\n```html\n// minified UMD module\n<script type=\"text/javascript\" src=\"./dist/mingo.min.js\"></script>\n\n// or gzipped UMD module\n<script type=\"text/javascript\" src=\"./dist/mingo.min.js.gz\"></script>\n```\n\nTiny configuration if needed\n```js\n// setup the key field for your collection\nmingo.setup({\n    key: '_id' // default\n});\n```\n\n## Using query object to test objects\n```js\n// create a query with criteria\n// find all grades for homework with score >= 50\nlet query = new mingo.Query({\n    type: \"homework\",\n    score: { $gte: 50 }\n});\n\n// test if an object matches query\nquery.test(someObject)\n```\n\n## Searching and Filtering\n```js\n// input is either an Array or any iterable source (i.e Object{next:Function}) including ES6 generators.\n\n// filter collection with find()\nlet cursor = query.find(collection)\n\n// shorthand with query criteria\ncursor = mingo.find(collection, criteria)\n\n// sort, skip and limit by chaining\ncursor.sort({student_id: 1, score: -1})\n    .skip(100)\n    .limit(100)\n\n// count matches. exhausts cursor\ncursor.count()\n\n// classic cursor iterator (old school)\nwhile (cursor.hasNext()) {\n    console.log(cursor.next())\n}\n\n// ES6 iterators (new cool)\nfor (let value of cursor) {\n  console.log(value)\n}\n\n// all() to retrieve matched objects. exhausts cursor\ncursor.all()\n```\n\n## Aggregation Pipeline\n```js\nlet agg = new mingo.Aggregator([\n    {'$match': { \"type\": \"homework\"}},\n    {'$group':{'_id':'$student_id', 'score':{$min:'$score'}}},\n    {'$sort':{'_id': 1, 'score': 1}}\n])\n\n// return an iterator for streaming results\nlet stream = agg.stream(collection)\n\n// return all results. same as `stream.all()`\nlet result = agg.run(collection)\n```\n\n## Integration with custom collection\n```js\n// using Backbone.Collection as an example (any user-defined object will do)\nlet Grades = Backbone.Collection.extend(mingo.CollectionMixin)\n\n// `collection` is an array of objects\nlet grades = new Grades(collection)\n\n// find students with grades less than 50 in homework or quiz\n// sort by score ascending and type descending\ncursor = grades.query({\n  $or: [{type: \"quiz\", score: {$lt: 50}}, {type: \"homework\", score: {$lt: 50}}]\n}).sort({score: 1, type: -1}).limit(10)\n\n// return grade with the lowest score\ncursor.next()\n```\n\nThe collection to mixin needs to provide a method with signature `toJSON() -> Array[Object]`.\n\n## Why?\n  - Alternative to writing lots of custom code for transforming collection of objects\n  - Quick validation of MongoDB queries without the need for a database\n  - MongoDB query language is among the best in the market and is well documented\n\n## Contributing\n* Submit pull requests to the [development](https://github.com/kofrasa/mingo/tree/development) branch\n* Squash changes into one commit\n* Run `make` to ensure tests pass\n\n## License\nMIT\n","readmeFilename":"README.md"}