maps-service/pkg/datastore/gormstore/submissions.go
2024-11-26 18:30:58 -05:00

24 lines
520 B
Go

package gormstore
import (
"context"
"errors"
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
"git.itzana.me/strafesnet/maps-service/pkg/model"
"gorm.io/gorm"
)
type Submissions struct {
db *gorm.DB
}
func (env *Submissions) Get(ctx context.Context, id int64) (model.Submission, error) {
var submission model.Submission
if err := env.db.First(&submission, id).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return submission, datastore.ErrNotExist
}
}
return submission, nil
}