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

Node revamp: PostgreSQL lessons #27960

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Conversation

01zulfi
Copy link
Member

@01zulfi 01zulfi commented May 11, 2024

Because

#27643

This PR

Adds installing and using PostgreSQL lessons

I've opted to separate it into two lessons as that what makes sense to me right now

Issue

Closes #27643

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project curriculum contributing guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

@01zulfi 01zulfi added the Project Node Revamp Issues/PRs related to the Node Revamp project label May 11, 2024
@github-actions github-actions bot added the Content: NodeJS Involves the NodeJS course label May 11, 2024
Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For installing_postgresql.md

nodeJS/express/installing_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/installing_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/installing_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/installing_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/installing_postgresql.md Outdated Show resolved Hide resolved
@01zulfi 01zulfi requested a review from MaoShizhong May 11, 2024 16:16
Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute 🔥

For using_postgresql.md:
Mainly just tiny wording nits

nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/using_postgresql.md Show resolved Hide resolved
nodeJS/express/using_postgresql.md Show resolved Hide resolved
nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
@01zulfi 01zulfi requested a review from MaoShizhong May 11, 2024 17:03
Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥
I'll add my approval now, though of course we'll probably want to wait for any others to get a chance to review.

nodeJS/express/installing_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/installing_postgresql.md Show resolved Hide resolved

<details markdown="block">

<summary class="dropDown-header">Linux</summary>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaoShizhong From your comment on the other PR, yeah the way we're doing these details/summary elements isn't great. Right now the heading structure from an AT perspective is essentially:

  • Installing PostgresSQL
    • Step 1: Make sure the system is up to date
    • ....other headings....
    • Step 1: Make sure the system is up to date

Without any context of an OS anywhere. We could put this in as is as I'm not 100% sure how best to go about it yet. We could have the actual steps be visible at all times, then in each step have a details/summary per OS, so something like the following screenshot:

image

Since the content of the summary element can't be given a Markdown heading (we could use HTML h3 etc, but then we need to allow that in the lint rules). But I'd have to stew on it a bit more probably.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thatblindgeye I straight up copy pasted the existing lesson in the Rails path in to a new file in this PR. If we do intend to make these changes, might I suggest handling it in a separate PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@01zulfi Oh no this is definitely something we're doing in other places, I hope my comment didn't come off as saying this was an issue you introduced or anything.

But yeah, this is something that can be a followup since it is something that will affect other lessons and there's still some ruminating to do on the idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good 😆

I'm suggesting to open a separate issue/PR because this issue is relevant to other installation-esque lessons as well. Anyway, I'm happy to update this PR if we do reach a consensus on how to fix this issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote separate PR to handle both this and the Rails version together once decided on the best way to handle this.
Single headings each with OS-specific dropdowns does look appealing, though IIRC @thatblindgeye, I think you mentioned accessibility issues with the current actual method of doing the dropdown itself? Since if we can find an accessible and logical alternative that also conforms to the heading issue, we'd be wanting to update any other lesson that does things like this, like any of the earlier installations lessons

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this all can be a followup


<summary class="dropDown-header">Linux</summary>

### Step 1: Make sure the system is up to date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The headings in these steps would need to be increased by one level since these are subsections of the larger "Installing PostgreSQL" section. Right now it would come off as this Step 1 section being more separate from "Installing" when it really isn't.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see above comment)

Copy link
Contributor

@fcasibu fcasibu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excited with this lesson! Coding along feels on point and it reads really nice, I will go through it again and maybe I can spot something else, but great job as always!

nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
With our initialized `Pool`, we can use the `query` method. Create a new `db/queries.js` file. Upon revising our project requirements, we understand we need two db interactions: getting all usernames and inserting a new username. Let's define these functions:

```javascript
const pool = require("./pool");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const pool = require("./pool");
const db = require("./pool");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended for this to stay as pool, but ended up using db in the code examples. Let me update to pool.

Invoke the above two functions in the specific controllers (you might have different function names etc. The important thing is to understand how the db functions are invoked):

```javascript
const db = require("../db/queries");
Copy link
Contributor

@fcasibu fcasibu May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commented above that named the pool module as db should we name this as query instead

await query.getAllUsernames();

await query.insertUsername(username);

Or we can make it more modular by creating db/queries/username.js and have generic names like Username.getAll() Username.insert() but it's up to you

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep it as db, though at the end of the day I really don't feel strongly towards it. I've updated the other code example., doo let me know what you prefer though after you're read that one; I'll update the lesson accordingly.

Regarding your suggestion on making it modular: I'll trust the learners to refactor as they see fit when they work on bigger projects. They already have all the knowledge they need to do Username.getAll() or however else they want to refactor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ adding to the above, you might've also noticed how barebones the script was compared to the version you wrote (which included utility functions etc). I'd rather have learners come up with this stuff

nodeJS/express/using_postgresql.md Outdated Show resolved Hide resolved
@01zulfi 01zulfi requested a review from fcasibu May 15, 2024 01:26
Co-authored-by: MaoShizhong <[email protected]>
Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other comments from me above require followups.

Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same - nothing further from me besides anything Nevz or anyone else wishes to bring up 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content: NodeJS Involves the NodeJS course Project Node Revamp Issues/PRs related to the Node Revamp project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Lesson: Using PostgreSQL
4 participants