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

Setup typeorm #7

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

Setup typeorm #7

wants to merge 4 commits into from

Conversation

echang594
Copy link
Collaborator

Info

Closes #6.

Description

What changes did you make? List all distinct problems that this PR addresses. Explain any relevant
motivation or context.

[description]

Changes

  • Installed TypeORM and TypeDI
  • Created DataSource to connect to database
  • Created UserModel, UserRepository, UserService
  • Injected dependencies into modules
  • Used transactions, no automatic retries for now
  • Types

Type of Change

  • Patch (non-breaking change/bugfix)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to not work as
    expected)
  • Documentation (A change to a README/description)
  • Continuous Integration/DevOps Change (Related to deployment steps, continuous integration
    workflows, linting, etc.)
  • Other: (Fill In)

If you've selected Patch, Minor, or Major as your change type, make sure to bump the version before merging in package.json!

Testing

I have tested that my changes fully resolve the linked issue ...

  • locally.
  • on the testing API/testing database.
  • with appropriate Postman routes. Screenshots are included below.

Checklist

  • I have performed a self-review of my own code.
  • I have followed the style guidelines of this project.
  • I have appropriately edited the API version in the package.json file.
  • My changes produce no new warnings.

Screenshots

Please include a screenshot of your Postman testing passing successfully.

@echang594 echang594 requested a review from jennymar November 5, 2024 08:41
Copy link

github-actions bot commented Nov 5, 2024

Thanks for contributing!
If you've made changes to the API's functionality, please make sure to bump the package
version—see this guide to semantic versioning for details—and
document those changes as appropriate.

@echang594 echang594 linked an issue Nov 5, 2024 that may be closed by this pull request
Copy link

@maxwn04 maxwn04 left a comment

Choose a reason for hiding this comment

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

Just a couple questions about how stuff is gonna work

import { ApplicationStatus, UserAccessType } from '../types/Enums';

@Entity()
export class UserModel {
Copy link

Choose a reason for hiding this comment

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

Is there a reason you aren't doing the extends BaseEntity with the Model? How are you planning to handle create/merge functions without it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found that there were two types of patterns we mixed in the membership portal for querying: Active Record, where the database query methods are part of the Model (in TypeORM this requires extending BaseEntity), and Data Mapper, where the query methods are part of a separate repository. I thought it was unnecessary to include both as all the functions are the same, so creating and merging would be done by accessing the repository instead.

private transactionsManager: TransactionsManager;

constructor(transactionsManager: TransactionsManager) {
this.transactionsManager = transactionsManager;
Copy link

Choose a reason for hiding this comment

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

Will all the services share a TransactionsManager? Or is it possible to put the DataSource into the constructor and use a new transactionsManager which would be a little closer to the membership portal currently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, all services will be injected with the same TransactionsManager. It is also possible to take the DataSource as an argument in the constructor and create a new TransactionsManager each time. I don't really have a strong opinion on this so if you think it would be better to match the membership portal I can change it.

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.

Setup TypeORM
2 participants