Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.26 KB

README.md

File metadata and controls

41 lines (29 loc) · 1.26 KB

Fluent SQL Builder

Npm version Minzip size 1 dependency Types included Travis Build Coverage Status


Description

@majortom327/sql-builder is a simple wrapper to build SQL queries as fluent object

Howto

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))"