minus-query
v0.0.1
Published
decode/encode query string prepended with sequelize or mongo comparison operators
Downloads
35
Maintainers
Readme
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>e-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'}}
}