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

Feature/refactor nest #61

Merged
merged 11 commits into from
Oct 17, 2024
Merged

Feature/refactor nest #61

merged 11 commits into from
Oct 17, 2024

Conversation

IkeHunter
Copy link
Collaborator

Refactor MongoDB to Postgres

Inspiration: https://www.youtube.com/watch?v=b2F-DItXtZs&list=LL&index=1&t=6s

Other reasons:

  • The data in the app is increasingly relying on inter-data relationships instead of plain objects of meta data with dynamic fields.
  • Trying to mold MongoDB to a fashion that was consistent with the ClubManager app (Django/Postgres) was becoming increasingly more burdensome.
  • Mongoose specifically did not handle types and relationships well, often needing "Jerry-Rigged" solutions to get something simple to work. For example, when a user deletes their link to spotify, the jukebox connection to that link should also delete. While there are a few solutions for this, it should ultimately be baked in to a supposed "ORM".

As a result of these issues, and general frustration with MongoDB given the types of data this project is working with, I refactored Mongoose to TypeORM, and switched out MongoDB with Postgres. TypeORM has an adaptor for MongoDB, but there is an open issue on their GitHub for implementing MongoDB relationships - and last I checked it's not a priority.

Other changes

  • Change the way data is shaped, forcing data to be snake case instead of camel case (ex: spotifyLink is now spotify_link). This was to improve consistency with ClubManager and the Spotify SDK.
  • Add some scripts and libraries to create a combined api documentation page. This page can be viewed in network mode at /api/docs/, and the api docs can be refreshed by running the script ./scripts/sync-api-docs.sh inside of the root project directory. The jukebox network dockercompose file and the clubmanager network dockercompose file need to be running for the docs to refresh, it pull the latest api spec from their respective urls.
  • Add PgAdmin to docker compose network file, this was to help debug some postgres stuff while setting up the db. It can be viewed at http://localhost:8888 when running in network mode.

More documentation on these changes to come.

@IkeHunter IkeHunter merged commit 3c52292 into main Oct 17, 2024
2 checks passed
@IkeHunter IkeHunter deleted the feature/refactor-nest branch October 17, 2024 15:48
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

Successfully merging this pull request may close these issues.

1 participant