
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
mongoose-query-parser
Advanced tools
Convert url query string to MongooseJs friendly query object including advanced filtering, sorting, population, string template, type casting and many more...
Convert url query string to MongooseJs friendly query object including advanced filtering, sorting, population, string template, type casting and many more...
The library is built highly inspired by api-query-params
$in, $regexp, …) and features (paging, projection, population, type casting, string templates…)fields v.s. select) and optionsimport { MongooseQueryParser } from 'mongoose-query-parser';
const parser = new MongooseQueryParser(options?: ParserOptions)
parser.parse(query: string, predefined: any) : QueryOptions
ParserOptions: object for advanced options (See below) [optional]query: query string part of the requested API URL (ie, firstName=John&limit=10). Works with already parsed object too (ie, {status: 'success'}) [required]predefined: object for predefined query context [optional]QueryOptions: object contains the following properties:
filter which contains the query criteriapopulate which contains the query population. Please see Mongoose Populate for more detailsselect which contains the query projectionsort, skip, limit which contains the cursor modifiers for paging purposeimport { MongooseQueryParser } from 'mongoose-query-parser';
const parser = new MongooseQueryParser();
const predefined = {
vip: { name: { $in: ['Google', 'Microsoft', 'NodeJs'] } }
sentStatus: 'sent'
};
const query = parser.parse('${vip}&status=${sentStatus}×tamp>2017-10-01&author.firstName=/john/i&limit=100&skip=50&sort=-timestamp&select=name&populate=children', predefined);
{
filter: {
{ name: { $in: ['Google', 'Microsoft', 'NodeJs'] } },
status: 'sent',
timestamp: { $gt: Fri Jan 01 2017 01:00:00 GMT+0100 (CET) },
'author.firstName': /john/i
},
sort: { timestamp: -1 },
skip: 50,
limit: 100,
select: { name },
populate: [{ path: 'children'}]
}
| MongoDB | URI | Example | Result |
|---|---|---|---|
$eq | key=val | type=public | {filter: {type: 'public'}} |
$gt | key>val | count>5 | {filter: {count: {$gt: 5}}} |
$gte | key>=val | rating>=9.5 | {filter: {rating: {$gte: 9.5}}} |
$lt | key<val | createdAt<2016-01-01 | {filter: {createdAt: {$lt: Fri Jan 01 2016 01:00:00 GMT+0100 (CET)}}} |
$lte | key<=val | score<=-5 | {filter: {score: {$lte: -5}}} |
$ne | key!=val | status!=success | {filter: {status: {$ne: 'success'}}} |
$in | key=val1,val2 | country=GB,US | {filter: {country: {$in: ['GB', 'US']}}} |
$nin | key!=val1,val2 | lang!=fr,en | {filter: {lang: {$nin: ['fr', 'en']}}} |
$exists | key | phone | {filter: {phone: {$exists: true}}} |
$exists | !key | !email | {filter: {email: {$exists: false}}} |
$regex | key=/value/<opts> | email=/@gmail\.com$/i | {filter: {email: /@gmail.com$/i}} |
$regex | key!=/value/<opts> | phone!=/^06/ | {filter: {phone: { $not: /^06/}}} |
For more advanced usage ($or, $type, $elemMatch, etc.), pass any MongoDB query filter object as JSON string in the filter query parameter, ie:
parser.parse('filter={"$or":[{"key1":"value1"},{"key2":"value2"}]}');
// {
// filter: {
// $or: [
// { key1: 'value1' },
// { key2: 'value2' }
// ]
// },
// }
FAQs
Convert url query string to MongooseJs friendly query object including advanced filtering, sorting, population, string template, type casting and many more...
We found that mongoose-query-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.