You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
692 B

  1. package Database
  2. import (
  3. "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Models"
  4. "gorm.io/gorm"
  5. "gorm.io/gorm/clause"
  6. )
  7. func CreatePostImage(postImageData *Models.PostImage) error {
  8. return DB.Session(&gorm.Session{FullSaveAssociations: true}).
  9. Create(postImageData).
  10. Error
  11. }
  12. func GetPostImageById(id string) (Models.PostImage, error) {
  13. var (
  14. postImageData Models.PostImage
  15. err error
  16. )
  17. err = DB.Preload(clause.Associations).
  18. First(&postImageData, "id = ?", id).
  19. Error
  20. return postImageData, err
  21. }
  22. func DeletePostImage(postImageData *Models.PostImage) error {
  23. return DB.Session(&gorm.Session{FullSaveAssociations: true}).
  24. Delete(postImageData).
  25. Error
  26. }