package Database import ( "github.com/gofrs/uuid" "gorm.io/gorm" "gorm.io/gorm/clause" ) // ConversationDetailUser all users associated with a conversation type ConversationDetailUser struct { Base ConversationDetailID uuid.UUID `gorm:"not null" json:"conversation_detail_id"` ConversationDetail ConversationDetail `gorm:"not null" json:"conversation"` UserID string `gorm:"not null" json:"user_id"` // Stored encrypted Username string `gorm:"not null" json:"username"` // Stored encrypted Admin string `gorm:"not null" json:"admin"` // Stored encrypted AssociationKey string `gorm:"not null" json:"association_key"` // Stored encrypted PublicKey string `gorm:"not null" json:"public_key"` // Stored encrypted } func GetConversationDetailUserById(id string) (ConversationDetailUser, error) { var ( messageThread ConversationDetailUser err error ) err = DB.Preload(clause.Associations). Where("id = ?", id). First(&messageThread). Error return messageThread, err } func (detailUser *ConversationDetailUser) CreateConversationDetailUser() error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Create(detailUser). Error } func (detailUser *ConversationDetailUser) UpdateConversationDetailUser() error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Where("id = ?", detailUser.ID). Updates(detailUser). Error } func (detailUser *ConversationDetailUser) DeleteConversationDetailUser() error { return DB.Session(&gorm.Session{FullSaveAssociations: true}). Delete(detailUser). Error }