Skip to content

roitinnovation/roit-sql-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple SQL query builder.

Topics

Resources

License

Stars

Watchers

Forks