Skip to content

MajorTom327/sql-builder

Repository files navigation

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

About

Create SQL Query as Fluent object in typescript

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published