
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Builds filters, projections and options for mongoose queries
attributes=comma,separated,fields
maps to projection { comma: 1, separated: 1, fields: 1 }
limit=1,offset=2
maps to options { limit: 1, offset: 2 }
sort=field
maps to options { sort: { field: 1 } }
sort=-field
maps to options { sort: { field: -1 } }
key=value
is { key: value }
key=value
is { key: /value/gi }
key,anotherKey=value
is $or: [{key:value}, {anotherKey:value}]
key__in=a,b,c
is key: $in: ["a","b","c"]
key__gt=value
is {key: { $gt: "value"} }
Qs2Mongo = require ("qs2mongo")
#Bind types to mongoose schema
qs2mongo = Qs2Mongo.MongooseSchema YourMongooseSchema, {...otherOptions...}
#Or manually specify types
qs2mongo = Qs2Mongo.ManualSchema {
filterableBooleans,
filterableNumbers,
filterableDates,
filterableObjectIds
}, {...otherOptions...}
#...
anEndpoint: (req, res): =>
{ filters, projection, options } = qs2mongo.parse req
Qs2Mongo = require ("qs2mongo")
config = ...
qs2mongo = new Qs2Mongo config
#...
router.use qs2mongo.middleware
#...
anEndpoint: (req, res): =>
{ filters, projection, options } = req.mongo
{
defaultSort,
idField = "id",
multigetIdField = "_id",
omitableProperties = Qs2Mongo.defaultOmitableProperties
}
Default driver is mongodb. If you'd like to use a custom mongodb driver, you must provide your own type conversion implementation as follows:
{
toObjectId: (it) -> #your conversion
toNumber: (it) -> #your conversion
toBoolean: (it) -> #your conversion
toDate: (it) -> #your conversion
}
Note: Your conversion must return the properly converted value if it
is valid or undefined
otherwise.
Specify the path to your implementation in process.env.QS_TRANSFORMER_DRIVER
FAQs
qs2mongo
The npm package qs2mongo receives a total of 477 weekly downloads. As such, qs2mongo popularity was classified as not popular.
We found that qs2mongo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.