sql-template-handler
v0.0.2
Published
This is an SQL template processor
Downloads
4
Readme
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 = '女士'