Merged in feature/document (pull request #36)
Document CRUD * doccreate * dochashlocandget * depsandtodo
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user