curriculum
curriculum copied to clipboard
[Eventonica Part 6 Postgres] Unclear or misleading instructions cause circular dependency
Page where problem found?
https://github.com/Techtonica/curriculum/blob/main/projects/eventonica-react/eventonica-postgres.md#instructions
Type of problem
Originally raised in Slack by @akivalencia
This is in reference to part 6 of eventonica which is connecting express server to postgres database…. (instructions for that are here)
Why do we initialize the database in index.js if it’s going to be used in model.js? This creates circular dependency since model.js doesn’t know what db is. I had to add pgp, and db in the model.js to get the api calls to work
Proposed Solution
DB connection should be isolated to the models.js module, since that should be the only code that can access the DB directly.
see #1608 for more context on the project.
- @gsong