Skip to content

Instantly share code, notes, and snippets.

@jakub-roman
Last active January 10, 2019 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakub-roman/49544021922d49acc8a8bdc308758e2e to your computer and use it in GitHub Desktop.
Save jakub-roman/49544021922d49acc8a8bdc308758e2e to your computer and use it in GitHub Desktop.
const format = require('pg-format')
var filter = [
{
c: "id",
o: "=",
v: "1"
},
{
c: "name",
o: "like",
v: "doasidn"
}
]
var insertFinJobs = function( filter ) {
var f = filter.map( i => { return `${i.c} ${i.o} '${i.v}'` } ).join(" AND ")
return format('select * from jobs_finished where 1 = 1 %s', f ? `AND ${f}` : '' )
}
console.log( insertFinJobs(filter) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment