|
|
- package Database
-
- import (
- "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Models"
-
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- )
-
- func CreatePostImage(postImageData *Models.PostImage) error {
- return DB.Session(&gorm.Session{FullSaveAssociations: true}).
- Create(postImageData).
- Error
- }
-
- func GetPostImageById(id string) (Models.PostImage, error) {
- var (
- postImageData Models.PostImage
- err error
- )
-
- err = DB.Preload(clause.Associations).
- First(&postImageData, "id = ?", id).
- Error
-
- return postImageData, err
- }
-
- func DeletePostImage(postImageData *Models.PostImage) error {
- return DB.Session(&gorm.Session{FullSaveAssociations: true}).
- Delete(postImageData).
- Error
- }
|