0.0.2 • Published 4 years ago

sql-template-handler v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

sql-template-handler

File directory

example
  |__test.sql
  |__index.js

index.js

const sql_template_handler = require('sql-template-handler')

const sql = sql_template_handler(__dirname+ '/test.sql', {
  month: '2020-01-01',
  age: 10,
  sex: 1
})

console.log(sql)

test.sql

select
*
from test
where month='{{ args.month }}'
{{ args.name && `and name='${args.name}'` }}
and age = {{ args.age + 10 }}
and sex = '{{ args.sex==0 ? '男士' : '女士' }}'

RESULT

select
*
from test
where month='2020-01-01'

and age = 20
and sex = '女士'
0.0.2

4 years ago

0.0.1

4 years ago