🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minus-query

decode/encode query string prepended with sequelize or mongo comparison operators

0.0.1
latest
Version published
Maintainers
1
Created

decode/encode query string prepended with sequelize or mongo/mongoose comparison operators

Sample (in express environment):

const minusQuery = requrie('minus-query')

app.use('/items', (req, res, next) => {
  const decoded = minusQuery.decode(req.query);
  model.find(decoded, {raw: true})
    .then(items => res.json(items))
    .catch(next)
})

In the example above the URL like: /items?eq-name=John&gte-age=30 would return all Johns who have their age greater or equal 30, by decoding the query parameters into where-expression like:

{
  name: {$eq: 'John'},
  age: {$gte: '30'}}
}

FAQs

Package last updated on 22 Mar 2017

Did you know?

Socket

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.

Install

Related posts