Last active
January 10, 2019 16:09
-
-
Save jakub-roman/49544021922d49acc8a8bdc308758e2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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