Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roitinnovation/roit-sql-builder
Simple SQL query builder.
https://github.com/roitinnovation/roit-sql-builder
nodejs sql typescript
Last synced: about 2 months ago
JSON representation
Simple SQL query builder.
- Host: GitHub
- URL: https://github.com/roitinnovation/roit-sql-builder
- Owner: roitinnovation
- License: mit
- Created: 2021-02-15T17:20:45.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-02T14:34:34.000Z (over 3 years ago)
- Last Synced: 2024-11-11T20:13:12.261Z (about 2 months ago)
- Topics: nodejs, sql, typescript
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ROIT SQL Builder
## Usage
Project structure must be like this:
```
root
│ README.md
└───src/
└───sql/
```
Create a class that mirrors your table:```typescript
export class Person {
name: string
age: number
}
```Create you SQL file with the parameters with @ in front of the name:
```sql
SELECT * FROM person p WHERE p.name = @name AND p.age = @age
```Import the method and use it:
```typescript
import { buildQueryString } from '@roit/roit-sql-builder'const person = new Person()
person.name = 'Keanu Reeves'
person.age = 46const query = buildQueryString('sql-file-name.sql', person)
console.log(query)
// Output:
// SELECT * FROM person p WHERE p.name = Keanu Reeves AND p.age = 46