package Database import ( "git.tovijaeschke.xyz/tovi/Envelope/Backend/Models" "gorm.io/gorm" "gorm.io/gorm/clause" ) func GetMessageThreadById(id string, user Models.User) (Models.MessageThread, error) { var ( messageThread Models.MessageThread err error ) err = DB.Preload(clause.Associations). Where("id = ?", id). Where("user_id = ?", user.ID). First(&messageThread). Error return messageThread, err } func CreateMessageThread(messageThread *Models.MessageThread) error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Create(messageThread). Error } func UpdateMessageThread(messageThread *Models.MessageThread) error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Where("id = ?", messageThread.ID). Updates(messageThread). Error } func DeleteMessageThread(messageThread *Models.MessageThread) error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Delete(messageThread). Error }