Gathering detailed insights and metrics for express-mquery
Gathering detailed insights and metrics for express-mquery
Gathering detailed insights and metrics for express-mquery
Gathering detailed insights and metrics for express-mquery
npm install express-mquery
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
40 Stars
211 Commits
8 Forks
2 Watching
6 Branches
3 Contributors
Updated on 06 May 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
45.5%
16
Compared to previous day
Last week
-64.5%
60
Compared to previous week
Last month
-15.4%
479
Compared to previous month
Last year
-2%
10,049
Compared to previous year
4
39
Expose mongoose query API through HTTP request with partial support of json-api:
Note: Checkout the current specification for more information.
1$ npm install --save express-mquery
1import expess from 'express'; 2import mquery from 'express-mquery'; 3 4const app = express(); 5app.use(mquery({ limit: 10, maxLimit: 50 })); 6 7... 8 9app.get('/users', (request, response, next) => { 10 11 // obtain request.mquery 12 console.log(request.mquery); 13 14});
Once parse, express-mquery
will extend http request
with mquery
field
Example:
1GET /invoices?fields=number,amount&filter[name]=Bob 2&filter[amount][$gte]=1200&include=customer,items 3&fields[customer]=name,number&fields[items]=name,price 4&page[number]=1&page[size]=10&sort[number]=1&sort[amount]=-1
Will be parsed into:
1{ 2 filter: { name: "Bob", amount: { $gte: 1200 } }, 3 paginate: { limit: 10, skip: 0, page: 1 }, 4 populate: [ 5 { path: "customer", select: { name: 1, number: 1 } }, 6 { path: "items", select: { name: 1, price: 1 } } 7 ], 8 select: { number: 1, amount: 1 }, 9 sort: { number: 1, amount: -1 } 10}
Where:
filter
: Is valid mongoose
criteria and can be passed to find()
paginate
: Contains paging details that can be passed to limit()
, skip()
populate
: Is valid mongoose
populate option and can be passed to populate()
select
: Is valid mongoose
project options and can be passed to select()
sort
: Is valid mongoose
sort options and can be passed to sort()
When passing values as objects or arrays in URLs, they must be valid JSON
1GET /customers?sort=name 2GET /customers?sort=-name 3GET /customers?sort={"name":1} 4GET /customers?sort={"name":1, "email":-1} 5 6or 7 8GET /customers?sort=name 9GET /customers?sort=-name 10GET /customers?sort[name]=1&sort[email]=-1
1GET /customers?page=1 2GET /customers?page=1&limit=10 3GET /customers?page[number]=1&page[size]=10
1GET /customers?skip=10
Only overrides maximum limit option set by the plugin
if the queried limit is lower
1GET /customers?limit=10
Supports all mongodb operators ($regex, $gt, $gte, $lt, $lte, $ne, etc.)
1GET /customers?query={"name":"Bob"} 2GET /customers?query={"name":{"$regex":"/Bo$/"}} 3GET /customers?query={"age":{"$gt":12}} 4GET /customers?query={"age":{"$gte":12}} 5 6or 7 8GET /customers?filter[name]=Bob 9GET /customers?filter[name][$regex]="/Bo$/" 10GET /customers?filter[age][$gt]=12 11GET /customers?filter[age][$gte]=12
Works with create, read and update operations
1GET /invoices?populate=customer 2GET /invoices?populate={"path":"customer"} 3GET /invoices?populate=[{"path":"customer"},{"path":"products"}] 4 5or 6 7GET /invoices?include=customer 8GET /invoices?include[customer]=name,number&includes[items]=name,price 9GET /invoices?include=customer,items&fields[customer]=name,number&fields[items]=name,price
_id
is always returned unless explicitely excluded
1GET /customers?select=name 2GET /customers?select=-name 3GET /customers?select={"name":1} 4GET /customers?select={"name":0} 5 6or 7 8GET /customers?fields=name 9GET /customers?fields=-name 10GET /customers?fields=name,email 11GET /invoices?include=customer&fields[customer]=name
Clone this repository
Install grunt-cli
global
1$ npm install -g grunt-cli
1$ npm install
1$ npm test
Fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.
Copyright (c) lykmapipo & Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/21 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
56 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More