-
Notifications
You must be signed in to change notification settings - Fork 62
840 short description for each video #1510
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
base: dev
Are you sure you want to change the base?
Changes from 17 commits
7fb318d
ae9ff7e
bc4ffe7
6844ab7
022bd59
b1f2927
c539464
b8cc26d
f28bf72
3f3c4f1
55ab7b2
b936700
5c6635e
d6d7cc4
9f9ddf3
4030e72
134ebc4
365a89b
b29498b
3b5e4c6
c580b9d
a5d2661
0185dee
5e51dfb
6170ef2
076e788
56f1acd
c2239a1
c923a00
681b37a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||
| package dao | ||||
|
karjo24 marked this conversation as resolved.
|
||||
|
|
||||
| import ( | ||||
| "github.com/TUM-Dev/gocast/model" | ||||
| "gorm.io/gorm" | ||||
| ) | ||||
|
|
||||
| //go:generate mockgen -source=user_defined_lecture_titles.go -destination ../mock_dao/user_defined_lecture_titles.go | ||||
|
|
||||
| type UserDefinedLectureTitlesDao interface { | ||||
| // Get UserDefinedLectureTitle by ID | ||||
| Get(uint, uint) (model.UserDefinedLectureTitle, error) | ||||
|
|
||||
| // Create a new UserDefinedLectureTitle for the database | ||||
| Create(*model.UserDefinedLectureTitle) error | ||||
|
|
||||
| // Delete a UserDefinedLectureTitle by user and stream id. | ||||
| Delete(uint, uint) error | ||||
|
|
||||
| // Upsert updates the entry if it exists, inserts it else | ||||
| Upsert(userLectureTitle *model.UserDefinedLectureTitle) error | ||||
| } | ||||
|
|
||||
| type userDefinedLectureTitlesDao struct { | ||||
| db *gorm.DB | ||||
| } | ||||
|
|
||||
| func NewUserDefinedLectureTitlesDao() UserDefinedLectureTitlesDao { | ||||
| return userDefinedLectureTitlesDao{db: DB} | ||||
| } | ||||
|
|
||||
| // Get a userDefinedLectureTitlesDao by userID and streamID | ||||
| func (d userDefinedLectureTitlesDao) Get(userID uint, streamID uint) (res model.UserDefinedLectureTitle, err error) { | ||||
| return res, d.db.First(&res, "user_id = ? AND stream_id = ?", userID, streamID).Error | ||||
| } | ||||
|
|
||||
| // Create a userDefinedLectureTitlesDao. | ||||
| func (d userDefinedLectureTitlesDao) Create(it *model.UserDefinedLectureTitle) error { | ||||
| return d.db.Create(it).Error | ||||
| } | ||||
|
|
||||
| // Delete a userDefinedLectureTitlesDao by id. | ||||
| func (d userDefinedLectureTitlesDao) Delete(userID uint, streamID uint) error { | ||||
| return d.db.Delete(&model.UserDefinedLectureTitle{}, "user_id = ? AND stream_id = ?", userID, streamID).Error | ||||
| } | ||||
|
|
||||
| // Upsert updates the entry if it exists, inserts it else | ||||
| func (d userDefinedLectureTitlesDao) Upsert(userLectureTitle *model.UserDefinedLectureTitle) error { | ||||
| return d.db.Save(userLectureTitle).Error | ||||
| } | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need upserting? With user_id and stream_id being composite primary keys, we can use create with a conflict clause to update a record. See e.g. Line 58 in fe0190d
I would go that way and rename the method to Save and drop Create and Upsert
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.