package Database
|
|
|
|
import (
|
|
"git.tovijaeschke.xyz/tovi/Envelope/Backend/Models"
|
|
|
|
"gorm.io/gorm/clause"
|
|
)
|
|
|
|
func GetSessionById(id string) (Models.Session, error) {
|
|
var (
|
|
session Models.Session
|
|
err error
|
|
)
|
|
|
|
err = DB.Preload(clause.Associations).
|
|
First(&session, "id = ?", id).
|
|
Error
|
|
|
|
return session, err
|
|
}
|
|
|
|
func CreateSession(session *Models.Session) error {
|
|
var (
|
|
err error
|
|
)
|
|
|
|
err = DB.Create(session).Error
|
|
|
|
return err
|
|
}
|
|
|
|
func DeleteSession(session *Models.Session) error {
|
|
return DB.Delete(session).Error
|
|
}
|
|
|
|
func DeleteSessionById(id string) error {
|
|
return DB.Delete(&Models.Session{}, id).Error
|
|
}
|