@roit/roit-sql-builder
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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

Package Sidebar

Install

npm i @roit/roit-sql-builder

Weekly Downloads

1

Version

0.0.7

License

none

Unpacked Size

17.2 kB

Total Files

16

Last publish

Collaborators

  • williampaulo
  • lucasmoreira
  • roitjoaovitor
  • jeremias.silva
  • karlaugust1
  • yucky4
  • tiagodev
  • jenkins.roit
  • tiago.gois
  • evelin.iurko.roit