@majortom327/sql-builder is a simple wrapper to build SQL queries as fluent object
Basic usage:
import { QueryBuilder } from '@majortom327/sql-builder'
const query = new QueryBuilder('table');
const buildedQuery: string = query.build(); // SELECT * FROM table
And advanced:
import { QueryBuilder } from '@majortom327/sql-builder'
const query = new QueryBuilder("table")
.where(new QueryWhere("field = 'value'")
.multiple()
.asAnd()
.add(new QueryWhere("field2 = '{{someVariableValue}}'"))
);
const buildedQuery = query.build({ someVariableValue: '1337'});
buildedQuery = "SELECT * FROM table WHERE ((field = 'value') AND (field2 = 1337))"