Last active
May 28, 2018 20:51
-
-
Save Sequoya42/54f008218300098f18873ebe1c391452 to your computer and use it in GitHub Desktop.
get data as JSON sql
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 whatIWant = { | |
username: 'u.username', | |
uid: 'u.id', | |
network: 'p.network' | |
}; | |
let testJsonSql = whatIwant => { | |
let ret = '"{",'; | |
for (k in whatIwant) { | |
ret += ` '"', "${k}" , '":"', ${whatIwant[k]}, '",'`; | |
} | |
ret = ret.substr(0, ret.length - 2) + `'"}"`; | |
console.log('ret', ret); | |
return ret; | |
}; | |
// Usage : | |
// `GROUP_CONCAT(DISTINCT ${testJsonSql( whatIWant )} SEPARATOR "∆∆∆") as lesBails` | |
// lesBails.split('∆∆∆').map(e => JSON.parse(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment