Encrypted messaging app
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.

56 lines
1.1 KiB

package Database
import (
"git.tovijaeschke.xyz/tovi/Envelope/Backend/Models"
"gorm.io/gorm"
)
func GetUserConversationById(id string) (Models.UserConversation, error) {
var (
message Models.UserConversation
err error
)
err = DB.First(&message, "id = ?", id).
Error
return message, err
}
func GetUserConversationsByUserId(id string) ([]Models.UserConversation, error) {
var (
conversations []Models.UserConversation
err error
)
err = DB.Find(&conversations, "user_id = ?", id).
Error
return conversations, err
}
func CreateUserConversation(userConversation *Models.UserConversation) error {
var err error
err = DB.Session(&gorm.Session{FullSaveAssociations: true}).
Create(userConversation).
Error
return err
}
func CreateUserConversations(userConversations *[]Models.UserConversation) error {
var err error
err = DB.Create(userConversations).
Error
return err
}
func DeleteUserConversation(userConversation *Models.UserConversation) error {
return DB.Session(&gorm.Session{FullSaveAssociations: true}).
Delete(userConversation).
Error
}