Last active
May 22, 2021 10:32
-
-
Save dipeshhkc/b4f793ac412a06b548cc82a9467d8770 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (db *userRepository) GetUser(id int) (user model.User, err error) { | |
return user, db.connection.First(&user, id).Error | |
} | |
func (db *userRepository) DeleteUser(user model.User) (model.User, error) { | |
if err := db.connection.First(&user, user.ID).Error; err != nil { | |
return user, err | |
} | |
return user, db.connection.Delete(&user).Error | |
} | |
func (db *userRepository) GetProductOrdered(userID int) (orders []model.Order, err error) { | |
return orders, db.connection.Where("user_id = ?", userID).Set("gorm:auto_preload", true).Find(&orders).Error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment