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

model depends on external package #3

Open
sinkevichmm opened this issue Apr 12, 2022 · 3 comments
Open

model depends on external package #3

sinkevichmm opened this issue Apr 12, 2022 · 3 comments

Comments

@sinkevichmm
Copy link

Hello! Why does your model have a dependency like "gorm.io/gorm". you will be forced to change the model if:

  1. the database provider will change (for example, from gorm to gopg)
  2. database type will change (mysql to mongodb)
    I think a method like BeforeCreate should be inside the repo in an implementation specific internal structure.
@restuwahyu13
Copy link
Owner

restuwahyu13 commented Apr 12, 2022

Because gorm.io/gorm is orm database and i use gorm orm for my application for interaction with database, beforeCreate is method from gorm this is hooks, check gorm documentation for more information about hooks, maybe next time, i will change gorm to gopg.

@sinkevichmm
Copy link
Author

sinkevichmm commented Apr 13, 2022

Untitled Diagram drawio

Of course i understand for what beforeCreate) In this case ModelStudent or ModelAuth is a business entity and "gorm.io/gorm" is a detail subject to change. Now you model depends on the detail. Do you agree?

@restuwahyu13
Copy link
Owner

yes correct

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

2 participants