So I want to display some data on front-end from the database.
My app.js file has included:
app.use('/database', databaseRoutes);
my database.js file is the next.
const { Pool, Client } = require('pg')
const connectionString = "postgres://dbuser:Storerage@localhost/mainstorage"
const client = new Client({
connectionString: connectionString,
})
client.connect()
client.query('SELECT * FROM files limit 10', (err, res) => {
console.log(err, res)
client.on("row", function (row, result) {
result.addRow(row);
});
});
module.exports = client;
How can I display this postgresql query result in document.component.html.
Can somebody link me any kind of help, or write an introduction ?
I think I need create a document.service file but I don't know how to handle that. I have read about JSON.stringify, but didn't find any cool tutorial.
Thanks for help.