-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Document running a basic hello world on heroku #1342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Milestone
Comments
schema.sql CREATE TABLE IF NOT EXISTS hello {
id BIGSERIAL PRIMARY KEY;
text TEXT DEFAULT '...';
} Run hello-world.js const {Pool} = require('pg');
const {parse} = require('pg-connection-string');
const dbConfig = Object.assign(parse(process.env.DATABASE_URL || 'pg://postgres@localhost/postgres'), {max: 9});
const pool = new Pool(dbConfig);
pool.query(`INSERT INTO hello(text) VALUES('world') RETURNING *`)
.then(({rows}) => console.log(rows))
.catch(console.error) Run |
Hopefully connection-string support won't require another module. |
I made a PR to make it simpler: const {Pool} = require('pg');
const parse = require('pg-connection-string');
const pool = new Pool(parse(process.env.DATABASE_URL || 'pg://postgres@localhost/postgres', {ssl:true, max: 2}));
pool.query(`INSERT INTO hello(text) VALUES('world') RETURNING *`)
.then(({rows}) => console.log(rows))
.catch(console.error) I hope the one integrated in pg will look like it I'd love to do: const {Pool} = require('pg');
// new Pool(opts) or new Pool(connectionString, opts)
const pool = new Pool(process.env.DATABASE_URL || 'pg://postgres@localhost/postgres', {ssl:true, max: 2});
pool.query(`INSERT INTO hello(text) VALUES('world') RETURNING *`)
.then(({rows}) => console.log(rows))
.catch(console.error) |
ahh! nice, I'll test that, thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: