maps-service/pkg/datastore/gormstore/submissions.go

24 lines
520 B
Go
Raw Normal View History

2024-11-26 21:36:40 +00:00
package gormstore
import (
"context"
2024-11-26 23:30:58 +00:00
"errors"
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
"git.itzana.me/strafesnet/maps-service/pkg/model"
2024-11-26 21:36:40 +00:00
"gorm.io/gorm"
)
2024-11-26 23:30:58 +00:00
type Submissions struct {
2024-11-26 21:36:40 +00:00
db *gorm.DB
}
2024-11-26 23:30:58 +00:00
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
2024-11-26 21:36:40 +00:00
}
}
2024-11-26 23:30:58 +00:00
return submission, nil
2024-11-26 21:36:40 +00:00
}