Skip to content

Instantly share code, notes, and snippets.

@Sequoya42
Last active May 28, 2018 20:51
Show Gist options
  • Save Sequoya42/54f008218300098f18873ebe1c391452 to your computer and use it in GitHub Desktop.
Save Sequoya42/54f008218300098f18873ebe1c391452 to your computer and use it in GitHub Desktop.
get data as JSON sql
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