Files
query-orchestration/internal/result/service.go
T

50 lines
980 B
Go
Raw Normal View History

2024-12-23 12:26:05 +00:00
package result
import (
2024-12-24 12:47:40 +00:00
"context"
2024-12-23 12:26:05 +00:00
"gotemplate/internal/database"
"gotemplate/internal/database/repository"
"github.com/google/uuid"
)
2024-12-24 12:47:40 +00:00
type Result struct {
ID uuid.UUID
QueryID uuid.UUID
QueryVersion int32
}
2024-12-23 12:26:05 +00:00
type Value struct {
ID uuid.UUID
QueryID uuid.UUID
Value string
}
2024-12-24 12:47:40 +00:00
type ResultStore struct {
QueryID uuid.UUID
DocumentID uuid.UUID
Value string
CleanVersion int32
TextVersion int32
QueryVersion int32
}
func Store(ctx context.Context, db *repository.Queries, res *ResultStore) (uuid.UUID, error) {
id := uuid.New()
err := db.SetResult(ctx, repository.SetResultParams{
ID: database.MustToDBUUID(id),
Queryid: database.MustToDBUUID(res.QueryID),
Documentid: database.MustToDBUUID(res.DocumentID),
Value: res.Value,
Cleanversion: res.CleanVersion,
Textversion: res.TextVersion,
Queryversion: res.QueryVersion,
})
if err != nil {
return uuid.Nil, err
2024-12-23 12:26:05 +00:00
}
2024-12-24 12:47:40 +00:00
return id, nil
2024-12-23 12:26:05 +00:00
}