0.0.7 • Published 3 years ago

@roit/roit-sql-builder v0.0.7

Weekly downloads
52
License
-
Repository
github
Last release
3 years ago

ROIT SQL Builder

Usage

Project structure must be like this:

root
│   README.md
└───src/
└───sql/

Create a class that mirrors your table:

export class Person {
    name: string
    age: number
}

Create you SQL file with the parameters with @ in front of the name:

SELECT * FROM person p WHERE p.name = @name AND p.age = @age

Import the method and use it:

import { buildQueryString } from '@roit/roit-sql-builder'

const person = new Person()
person.name = 'Keanu Reeves'
person.age = 46

const query = buildQueryString<Person>('sql-file-name.sql', person)
console.log(query)
// Output: 
// SELECT * FROM person p WHERE p.name = Keanu Reeves AND p.age = 46
0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago