Skip to content
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

Simplify database connection #34

Open
oliverjam opened this issue Apr 22, 2019 · 5 comments
Open

Simplify database connection #34

oliverjam opened this issue Apr 22, 2019 · 5 comments
Assignees

Comments

@oliverjam
Copy link

oliverjam commented Apr 22, 2019

As I mentioned in this Master Reference issue, the database connection code we've always started students off with is unnecessarily complex.

We can drop almost all the connection string parsing and give it straight to pg:

const { Pool } = require("pg");
require('env2')('./config.env');

const connectionString = process.env.DB_URL;

if (!connectionString) throw new Error("Please set a DB_URL environment variable");

module.exports = new Pool({
  connectionString,
  ssl: !connectionString.includes("localhost")
});

I'm happy to go through all the steps and make the change—it should probably be done for all the workshops this week so the db setup is always consistent.

@astroash
Copy link

@oliverjam sounds like a great idea. Do we know how many workshops this is covered in?

@oliverjam
Copy link
Author

@astroash sooo many 🙃

I've raised an issue on the initial codealong where we introduce pg. I'll try and do PRs one by one for all the places we have a db_connection.js

@shiryz
Copy link
Member

shiryz commented May 3, 2019

@oliverjam using connectionString shortens the workshop by at least half an hour, we've already tested it before and I'm all in favour of using it.
Like you said so many WSs are built on top of this one and would need to be modified as well...

jema28 added a commit to jema28/pg-walkthrough that referenced this issue Jul 15, 2019
@samjam48
Copy link

samjam48 commented Dec 5, 2019

This does seem like a great idea @oliverjam

Going through this definitely took a while. also explaining all the object destructuring and assigning added a bunch of time that wasn't needed and mostly forgotten till they get round to it later in the course anyway.

I'm happy dividing the task if you're still interested in doing it?

@samjam48
Copy link

samjam48 commented Dec 5, 2019

Thanks @jema28 for amending the step 3 code. I led the workshop following from the "mentor notes" which weren't amended 🙈
I've updated them to match so that hopefully this mistake doesn't happen again. if someone can accept that change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants