{"_id":"@asymmetrik/mongoose-query-service","_rev":"9-473fa439457c26fafc0903c163413b4f","name":"@asymmetrik/mongoose-query-service","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"@asymmetrik/mongoose-query-service","version":"0.1.0","author":{"name":"Asymmetrik, Ltd."},"license":"MIT","_id":"@asymmetrik/mongoose-query-service@0.1.0","maintainers":[{"name":"asymmetrik","email":"ryan@asymmetrik.com"}],"homepage":"https://github.com/asymmetrik/mongoose-query-service#readme","bugs":{"url":"https://github.com/asymmetrik/mongoose-query-service/issues"},"dist":{"shasum":"ae4c9ac0ad4879a2eac4fb34c97b3c7c57a27188","tarball":"https://registry.npmjs.org/@asymmetrik/mongoose-query-service/-/mongoose-query-service-0.1.0.tgz","integrity":"sha512-X1IHfGbl/wjSSBUfWU0C5WOUiHgc+44UsfsIKJbiqKLQCWf8NhjHhzcZPnQgdZLP2E3v4akpnvgFPzmRREopow==","signatures":[{"sig":"MEUCIQCLwRgg6XSuQjzRZe+rPOh43uSb7cFxDTB+OPCOJ/abrQIgdn3R0IPI5ezoPSSFRhFitl0e9V9wx1CywNq3jCmMpO4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"_from":".","_shasum":"ae4c9ac0ad4879a2eac4fb34c97b3c7c57a27188","engines":{"npm":"3.3.10","node":"6.9"},"gitHead":"533fdbac7e474ce2d93510f38de9a34d0a31d3db","scripts":{"dev":"gulp dev","test":"gulp test-ci","dev-test":"gulp dev-test"},"_npmUser":{"name":"asymmetrik","email":"ryan@asymmetrik.com"},"copyright":"Copyright Asymmetrik, Ltd. 2007-2017 - All Rights Reserved.","repository":{"url":"git+https://github.com/asymmetrik/mongoose-query-service.git","type":"git"},"_npmVersion":"3.10.8","description":"NPM module to provide shareable services and plugins for Mongoose models","directories":{},"_nodeVersion":"6.9.1","dependencies":{"lodash":"4.17"},"devDependencies":{"gulp":"3.9","mocha":"3.2","yargs":"6.6","should":"11.1","mongoose":"4.x","gulp-util":"3.0","gulp-mocha":"3.0","gulp-watch":"4.3","gulp-eslint":"3.0","run-sequence":"1.2","gulp-coverage":"0.3","gulp-istanbul":"1.1","gulp-load-plugins":"1.4"},"peerDependencies":{"mongoose":"4.x"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-query-service-0.1.0.tgz_1489407588208_0.29219591128639877","host":"packages-18-east.internal.npmjs.com"}},"0.1.1":{"name":"@asymmetrik/mongoose-query-service","version":"0.1.1","author":{"name":"Asymmetrik, Ltd."},"license":"MIT","_id":"@asymmetrik/mongoose-query-service@0.1.1","maintainers":[{"name":"asymmetrik","email":"ryan@asymmetrik.com"}],"homepage":"https://github.com/asymmetrik/mongoose-query-service#readme","bugs":{"url":"https://github.com/asymmetrik/mongoose-query-service/issues"},"dist":{"shasum":"6b188040c0062a18bc3f64ca0569d4cbb1d1cb83","tarball":"https://registry.npmjs.org/@asymmetrik/mongoose-query-service/-/mongoose-query-service-0.1.1.tgz","integrity":"sha512-Ae8H+v5t0OBO7HvO0EUIQ9nKLDXJCOBv+vm0UUaZzz0jaDcR7YP1h5fG2Gpda6EjnTODnF0r402XDrRzvxFmIA==","signatures":[{"sig":"MEUCIQDDiiicxKnCR1vE4bc9FY9VYVSXzo3MLIt3/3zo90ZIBAIgcf58c9hiQrfexshA3IsVQonL0bFOQ4dMtDq0/OQdQvU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"_from":".","_shasum":"6b188040c0062a18bc3f64ca0569d4cbb1d1cb83","engines":{"npm":"3.3.10","node":"6.9"},"gitHead":"63e5042168d4809c154a131324721af759489661","scripts":{"dev":"gulp dev","test":"gulp test-ci","dev-test":"gulp dev-test"},"_npmUser":{"name":"asymmetrik","email":"ryan@asymmetrik.com"},"copyright":"Copyright Asymmetrik, Ltd. 2007-2017 - All Rights Reserved.","repository":{"url":"git+https://github.com/asymmetrik/mongoose-query-service.git","type":"git"},"_npmVersion":"3.10.8","description":"NPM module to provide shareable services and plugins for Mongoose models","directories":{},"_nodeVersion":"6.9.1","dependencies":{"lodash":"4.17"},"devDependencies":{"gulp":"3.9","mocha":"3.2","yargs":"6.6","should":"11.1","mongoose":"4.x","gulp-util":"3.0","gulp-mocha":"3.0","gulp-watch":"4.3","gulp-eslint":"3.0","run-sequence":"1.2","gulp-coverage":"0.3","gulp-istanbul":"1.1","gulp-load-plugins":"1.4"},"peerDependencies":{"mongoose":"4.x"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-query-service-0.1.1.tgz_1489584240115_0.9600083085242659","host":"packages-12-west.internal.npmjs.com"}},"0.2.0":{"name":"@asymmetrik/mongoose-query-service","version":"0.2.0","author":{"name":"Asymmetrik, Ltd."},"license":"MIT","_id":"@asymmetrik/mongoose-query-service@0.2.0","maintainers":[{"name":"asymmetrik","email":"ryan@asymmetrik.com"}],"homepage":"https://github.com/asymmetrik/mongoose-query-service#readme","bugs":{"url":"https://github.com/asymmetrik/mongoose-query-service/issues"},"dist":{"shasum":"4edbfc5b7cb1d528665c5120a0415aa72f6e4431","tarball":"https://registry.npmjs.org/@asymmetrik/mongoose-query-service/-/mongoose-query-service-0.2.0.tgz","integrity":"sha512-+ThYJ1ny5kWNpxylX/KASiUuAOKM5vQV/uWiZ3+oBEaxSuXceaQIoTWNFqIPzpLhVIYOyAJoY4psHxwYO8sJMA==","signatures":[{"sig":"MEUCIQCHofXN5BOX9DslEFczofFM+R46SsksNs1B3qSiC0aG4gIgJzO1rJUwq1kcHyHT8yryzCybqQ3HUC7nSCJU+O8JscY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"_from":".","_shasum":"4edbfc5b7cb1d528665c5120a0415aa72f6e4431","engines":{"npm":"3.3.10","node":"6.9"},"gitHead":"779ace8f88b870d3d2b8cf71477567dacf61f80b","scripts":{"dev":"gulp dev","test":"gulp test-ci","dev-test":"gulp dev-test"},"_npmUser":{"name":"asymmetrik","email":"ryan@asymmetrik.com"},"copyright":"Copyright Asymmetrik, Ltd. 2007-2017 - All Rights Reserved.","repository":{"url":"git+https://github.com/asymmetrik/mongoose-query-service.git","type":"git"},"_npmVersion":"3.10.8","description":"NPM module to provide shareable services and plugins for Mongoose models","directories":{},"_nodeVersion":"6.9.1","dependencies":{"lodash":"4.17"},"devDependencies":{"gulp":"3.9","mocha":"3.2","yargs":"6.6","should":"11.1","mongoose":"4.x","gulp-util":"3.0","gulp-mocha":"3.0","gulp-watch":"4.3","gulp-eslint":"3.0","run-sequence":"1.2","gulp-coverage":"0.3","gulp-istanbul":"1.1","gulp-load-plugins":"1.4"},"peerDependencies":{"mongoose":"4.x"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-query-service-0.2.0.tgz_1490293222130_0.4230466817971319","host":"packages-12-west.internal.npmjs.com"}},"1.0.0":{"name":"@asymmetrik/mongoose-query-service","version":"1.0.0","keywords":["mongoose"],"author":{"name":"Asymmetrik, Ltd."},"license":"MIT","_id":"@asymmetrik/mongoose-query-service@1.0.0","maintainers":[{"name":"brianghig","email":"brianghig@gmail.com"},{"name":"rblace","email":"ryan@asymmetrik.com"}],"homepage":"https://github.com/asymmetrik/mongoose-query-service#readme","bugs":{"url":"https://github.com/asymmetrik/mongoose-query-service/issues"},"dist":{"shasum":"46a29916ef7d03ec981384a05dfeb73119059b87","tarball":"https://registry.npmjs.org/@asymmetrik/mongoose-query-service/-/mongoose-query-service-1.0.0.tgz","fileCount":19,"integrity":"sha512-nIwXhPtei6CiEq5yG7Fm1HoV3JB2lxMQPRYosJYnJ8c0AQgzCMysQqjoVPydfCWcHWOfUh9jVv6OinwgFvioMA==","signatures":[{"sig":"MEQCIDRuEvzU7RwKrA94Qeb6Bxa8lkuvSuiTH6mFC3awSHa9AiB3eJPLckkkpG8e/eTzcZxKXfsYw2z1PAOjk/Y+K/93XQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35956,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiqyJTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmquTQ/9H1bMSe8+Eph5gexzgJd1qL/WI/zIVMPRugYQ3aiK4AZIM9Gl\r\nZR3DDTR6HPnw+X+04Y/uo66cXubKz1O28Mbl8JENq+7T+6uj5n/4NBvqqzYU\r\nEnWOfV1xiErkA2o67ydVxpsbs77L6PvF5yIFzEI1rNIfbNaNXRO9DYp+CkRP\r\nhswNxd8ahWv8bCoGWCb/XArhvnAyQPtAsJO/KK8OzMUK1BhWsfw9DeYO2TT8\r\nEG3N8/EGycjhLVrprkO1JwJgnpIawgBc7kmHD0myeca+eWlEOSnhXx7+JI/G\r\niVRCc0x5Yaeyc8UR55HUGmlU6tIr1cjQViUkPRq1WFH+zAH2QjJEVRr4o8PS\r\nOEOXX84vucyTwVB2aj+jwCY083SG+WSjfdDORhGxeoiJlLYeJ7yJdhYf4Mqx\r\nQgw/tnzhPaNPP2yyOq9Y1YNSD76huxjst/i4e7l6JnIVFbo+33UXR4KeYZnI\r\nvj8e/97T+zJlHGJ4KljC32qzio/zDUd/7X4GegmXbjSdxtTfF8mEsPZZ57HI\r\nFWHqyjO1lU6+PsEb4Cz787tFb+cY/GcYO0aRbcnUr60qymSHee0VMgTQqnao\r\n/zkLURhBBy6B8jgURs2HMOmnwmWexa8FV+LqZQWYf7/82QV7knNcdRt4ZG3Z\r\ntK23uAj/VSycJZdEO+3bVTiZxcbbYYz/oiM=\r\n=2E57\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","engines":{"npm":"8","node":"16"},"gitHead":"b930aafaf941bf5d1856a9fa77b77726da9e16fe","scripts":{"lint":"eslint --fix","test":"nyc --reporter=cobertura --reporter=lcov --reporter=text-summary mocha"},"_npmUser":{"name":"brianghig","email":"brianghig@gmail.com"},"copyright":"Copyright Asymmetrik, Ltd. 2007-2022 - All Rights Reserved.","repository":{"url":"git+https://github.com/asymmetrik/mongoose-query-service.git","type":"git"},"_npmVersion":"8.5.5","description":"NPM module to provide shareable services and plugins for Mongoose models","directories":{"test":"test"},"_nodeVersion":"16.15.0","dependencies":{"lodash":"4.17"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"15.1.0","mocha":"10.0.0","yargs":"17.5.1","eslint":"8.17.0","should":"13.2.3","mongoose":"5.x"},"peerDependencies":{"mongoose":"5.x"},"_npmOperationalInternal":{"tmp":"tmp/mongoose-query-service_1.0.0_1655382611772_0.5568041096739758","host":"s3://npm-registry-packages"}}},"time":{"created":"2017-03-13T12:19:48.839Z","modified":"2026-03-13T16:28:27.301Z","0.1.0":"2017-03-13T12:19:48.839Z","0.1.1":"2017-03-15T13:24:02.233Z","0.2.0":"2017-03-23T18:20:24.483Z","1.0.0":"2022-06-16T12:30:11.960Z"},"bugs":{"url":"https://github.com/asymmetrik/mongoose-query-service/issues"},"author":{"name":"Asymmetrik, Ltd."},"license":"MIT","homepage":"https://github.com/asymmetrik/mongoose-query-service#readme","keywords":["mongoose"],"repository":{"url":"git+https://github.com/asymmetrik/mongoose-query-service.git","type":"git"},"description":"NPM module to provide shareable services and plugins for Mongoose models","maintainers":[{"email":"ryan.blace@bluehalo.com","name":"rblace"}],"readme":"# @asymmetrik/mongoose-query-service\n\n[![Build Status](https://travis-ci.org/Asymmetrik/mongoose-query-service.svg)](https://travis-ci.org/Asymmetrik/mongoose-query-service)\n[![Code Climate](https://codeclimate.com/github/Asymmetrik/mongoose-query-service/badges/gpa.svg)](https://codeclimate.com/github/Asymmetrik/mongoose-query-service)\n[![Test Coverage](https://codeclimate.com/github/Asymmetrik/mongoose-query-service/badges/coverage.svg)](https://codeclimate.com/github/Asymmetrik/mongoose-query-service/coverage)\n[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)\n\n> NPM module to provide common services and plugins for Mongoose models\n\n## Table of Contents\n\n- [Use](#use)\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n- [Contribute](#contribute)\n- [License](#license)\n\n## Use\n`@asymmetrik/mongoose-query-service` provides utility services for creating and executing Mongoose queries based on a simple input search object. Additionally, it provides several plugins (`pageable` and `gettable`) that can be applied to Mongoose Schemas to allow them to add functionality to those Mongoose Schemas.\n\n## Install\n\nInclude this module as a dependency of your application in the `package.json` file. For example:\n```\n{\n  ...\n  dependencies: {\n    \"@asymmetrik/mongoose-query-service\": \"latest\"\n  }\n  ...\n}\n```\n\n## Usage\n\nInclude the module via `require` wherever applicable:\n```\nvar mongooseQueryService = require('@asymmetrik/mongoose-query-service');\n```\n\n### Plugins\n\nApply any of the plugins to a Mongoose model using the `.plugin(...)` method provided by Mongoose. For example:\n```\nvar Person = new Schema({});\nPerson.plugin(mongooseQueryService.plugins.pageable);\n```\n\n### Services\n\nService methods are available from the base `@asymmetrik/mongoose-query-service` module, and can be called directly with the parameters defined in the API below.\n\n## API\n\n### Plugins\n\nThe following plugins are available at the top level `plugins` attribute:\n\n#### pageable\n\nApplying the `pageable` plugin at `mongooseQueryService.plugins.pageable` adds a static method to Mongoose model called `pagingSearch` that takes an input object parameter with the following attributes:\n\nAttribute | Optional? | Default | Description\n------------ | ------------- | ------------ | -------------\nquery | Yes | `{}` | Filters to pass to the Mongo query\nprojection | Yes | `{}` | Attributes to return in the elements\noptions | Yes | `{}` | Query options specified by Mongoose\nsearchTerms | Yes | null | String of search terms that will be translated into a search on the text index for the model\npopulate | Yes | null | Populate options specified by Mongoose\nsorting | Yes | {} | Attributes for sorting and directions of each sort. Defaults to descending sort. Accepts either an object with a standard Mongo sorting config or an array of objects with `property` and `direction` attributes that will be translated into the standard Mongo sorting config.\npage | Yes | 0 | To support paged searches, combines with `limit` to set the `skip` attribute of the Mongo query. If `limit` is not provided, `page` is not used.\nlimit | Yes | null | If provided, returns up to this number of results. Combines with the `page` parameter when setting the `skip` attribute of the Mongo query\n\nThe `pagingSearch` method returns a Promise resolved with an object with the following attributes:\n\nAttribute | Type | Description\n------------ | ------------- | ------------\nhasMore | Boolean | Indicates if more documents are available if the next page of results is queried\ntotalSize | Number | The total count of documents that passed the query filter\npageNumber | Number | The current page of results returned. `0` if not paging\npageSize | Number | The current size of each page returned. Set to the input `limit` value (if provided) or the actual size\ntotalPages | Number | The number of pages from the the total size and page size configuration\nelements | Array | The results that were found matching the current page.\n\n*Example:*\n```\nvar Person = new Schema({});\nPerson.plugin(mongooseQuerySchema.plugins.pageable);\n```\n\n#### gettable\n\nApplying the `gettable` plugin at `mongooseQueryService.plugins.gettable` sets the `toObject` and `toJSON` attributes of the Mongoose Schema to `{ getters: true }` so that any `get` method defined in a Schema Type is used when the `toObject` or `toJSON` methods are invoked on the Mongoose model.\n\n*Example:*\n```\nvar Person = new Schema({});\nPerson.plugin(mongooseQuerySchema.plugins.gettable);\n```\n\n### Services\n\n#### buildQuery(query, pagingParameters)\n\nConverts input query and paging parameters into a pageable query object to be used with the `pageable` plugin's `pagingSearch` function.\n\nReturns a promise resolved with the resulting search config object with the attributes:\n\nAttribute | Type | Description\n------------ | ------------- | ------------\nquery | Boolean | Indicates if more documents are available if the next page of results is queried\nsorting | Object | If a `sort` attribute of `pagingParameters` is set, builds a sorting object with a direction set by the `dir` attribute (defaulting to -1 for descending, or set by 'DESC' or 'ASC').\npage | Number | Set by the input `page` attribute of `pagingParameters` passed into the `getPage` method\nlimit | Number | Set by the input `size` attribute of `pagingParameters` passed into the `getLimit` method\n\n#### validateNonEmpty\nReturns true of the input value is not empty (using the lodash *isEmpty* function)\n\n#### parseDate\nParse an input as a date. Handles various types of inputs, such as Strings, Date objects, and Numbers.\n\n@param {date} The input representing a date / timestamp\n\n@returns The timestamp in milliseconds since the Unix epoch\n\n#### getLimit\nGet the limit provided by the input query parameters, if there is one. Limit is taken from the `size` attribute of the input `queryParams` object. Limit has to be at least 1 with a default value of 20 and no more than the max value.\n\n@param queryParams\n\n@param maxSize (optional) default: 100\n\n@returns {number}\n\n#### getPage\nPage needs to be positive and has no upper bound. Taken from the `page` attribute of the input `queryParams` object. Defaults to 0.\n\n@param queryParams\n\n@returns {number}\n\n#### contains\nDetermine if an array contains a given element by doing a deep comparison.\n\n@param arr\n\n@param element\n\n@returns {boolean} True if the array contains the given element, false otherwise.\n\n#### toMongoose\nConverts an input Mongo query, possibly with $date and $obj attributes, to a query that Mongoose supports with Date and ObjectId objects mapped from those inputs as appropriate.\n\n@param obj\n\n@returns {object}\n\n## Contribute\n\nPRs accepted.\n\n\n## License\n\nSee LICENSE for details\n","readmeFilename":"README.md"}