It is possible to directly access the Retool Database via a JS function or JS block, or is the only way to interact with the DB data via a query?
For instance can you use node-postgres to interact directly with the db? Ideally Retool would manage the authentication or allow access to the a client with access to the databse.
I suspect this is not possible, but just wanted to confirm. If someone does have it working could they share a sample of their code?
An example of how this might look is below
const { Client } = require('pg');
const client = new Client({
host: 'your_database_host',
port: 5432,
user: 'your_database_user',
password: 'your_password',
database: 'your_database_name'
});
async function fetchData() {
await client.connect();
const res = await client.query('SELECT * FROM your_table_name');
console.log(res.rows);
await client.end();
}
fetchData();