Files
archived-starters/javascript/with-postgres/index.js
Jake Runzer 256cce952e Cleanup examples (#16)
- Remove serverless example (it was basically dup of with-postgres)
- Add plugin (e.g. postgres) to example name
- Update all javascript examples and make sure they work
- Cleanup a bit of the ui in nextjs example
2020-11-24 22:23:23 +00:00

19 lines
360 B
JavaScript

const pg = require("pg");
// Connect to the database using the DATABASE_URL environment
// variable injected by Railway
const pool = new pg.Pool();
const go = async () => {
// Query the database
const res = await pool.query("SELECT NOW()");
// Print the result
console.log(res.rows[0]);
// Close the database connection
pool.end();
};
go();