package Database import ( "git.tovijaeschke.xyz/tovi/Envelope/Backend/Models" "gorm.io/gorm" "gorm.io/gorm/clause" ) func GetConversationDetailById(id string) (Models.ConversationDetail, error) { var ( messageThread Models.ConversationDetail err error ) err = DB.Preload(clause.Associations). Where("id = ?", id). First(&messageThread). Error return messageThread, err } func GetConversationDetailsByIds(id []string) ([]Models.ConversationDetail, error) { var ( messageThread []Models.ConversationDetail err error ) err = DB.Preload(clause.Associations). Where("id IN ?", id). First(&messageThread). Error return messageThread, err } func CreateConversationDetail(messageThread *Models.ConversationDetail) error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Create(messageThread). Error } func UpdateConversationDetail(messageThread *Models.ConversationDetail) error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Where("id = ?", messageThread.ID). Updates(messageThread). Error } func DeleteConversationDetail(messageThread *Models.ConversationDetail) error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Delete(messageThread). Error }