I'm setting up a local script to setup a website locally and was trying to get some data from mysql.
const util = require('util');
const exec = util.promisify(require('child_process').exec);
class Setup {
constructor() {}
async setLocalURLs(){
const base_urls = await exec(`mysql -h${this.configFile.database.host} -u${this.configFile.database.username} -D ${this.databaseName} -p${this.configFile.database.password} -e 'SELECT id, value FROM table'`);
console.warn(base_urls.stdout)
}
}
module.exports = Setup;
It worked completely but I'm getting the results as new lines. Results from my commandline data below:
2747 valueA
2748 valueB
2749 valueC
2750 valueD
2751 valueE
Is it possible to output this as an obj or array instead of newlines within 'util'? (ofcourse without split on tab etc, I can do that myself ;))