package Database
|
|
|
|
import (
|
|
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Models"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
)
|
|
|
|
func GetConversationDetailUserById(id string) (Models.ConversationDetailUser, error) {
|
|
var (
|
|
messageThread Models.ConversationDetailUser
|
|
err error
|
|
)
|
|
|
|
err = DB.Preload(clause.Associations).
|
|
Where("id = ?", id).
|
|
First(&messageThread).
|
|
Error
|
|
|
|
return messageThread, err
|
|
}
|
|
|
|
func CreateConversationDetailUser(messageThread *Models.ConversationDetailUser) error {
|
|
return DB.Session(&gorm.Session{FullSaveAssociations: true}).
|
|
Create(messageThread).
|
|
Error
|
|
}
|
|
|
|
func UpdateConversationDetailUser(messageThread *Models.ConversationDetailUser) error {
|
|
return DB.Session(&gorm.Session{FullSaveAssociations: true}).
|
|
Where("id = ?", messageThread.ID).
|
|
Updates(messageThread).
|
|
Error
|
|
}
|
|
|
|
func DeleteConversationDetailUser(messageThread *Models.ConversationDetailUser) error {
|
|
return DB.Session(&gorm.Session{FullSaveAssociations: true}).
|
|
Delete(messageThread).
|
|
Error
|
|
}
|