qsql
v1.0.0
Published
# An Express middleware to convert query parameters to SQL query.
Downloads
3
Readme
Attention: not for a usage in current status. In deep development! Please, don't install it for now. Wait for the future versions.
An Express middleware to convert query parameters to SQL query.
Features
- Provide a simple language on-top of url query parameters format to constructing SQL queries.
- Automatically construct
knex
builder object based on query parameters. - Provide ability to get raw SQL query as string or with bindings to use anywhere.
Install
npm i qsql --save
Usage
Configuration
const qsql = require('qsql');
const express = require('express');
const app = express();
app.use(qsql({
client: 'pg'
}));
app.get('/products', (req, res, next) => {
// req.qsql - ready to use `knex` builder
// use req.qsql.toString() to get SQL query as string
// use req.qsql.toSQL() to get SQL query with bindings
});
app.listen(process.env.PORT);