Merged in feature/document (pull request #36)

Document CRUD

* doccreate

* dochashlocandget

* depsandtodo
This commit is contained in:
Michael McGuinness
2025-01-24 16:12:25 +00:00
parent 4ec1d51a12
commit b16ff55afa
31 changed files with 381 additions and 82 deletions
+41
View File
@@ -0,0 +1,41 @@
package document
import (
"context"
"queryorchestration/internal/database"
"queryorchestration/internal/database/repository"
"github.com/google/uuid"
)
type Location = string
type Create struct {
JobID uuid.UUID
Location Location
}
func (s *Service) Create(ctx context.Context, doc *Create) (uuid.UUID, error) {
hash, err := s.getHash()
if err != nil {
return uuid.Nil, err
}
dbid, err := s.db.Queries.CreateDocument(ctx, &repository.CreateDocumentParams{
Jobid: database.MustToDBUUID(doc.JobID),
Hash: hash,
Location: doc.Location,
})
if err != nil {
return uuid.Nil, err
}
id := database.MustToUUID(dbid)
return id, nil
}
func (s *Service) getHash() (string, error) {
// TODO
return "example_hash", nil
}