Compare commits

..

No commits in common. "c7176fadf645605b3636621049015cd464d12246" and "00ab98072be88636806eac6ea507c98153bbeac8" have entirely different histories.

3 changed files with 20 additions and 17 deletions

View File

@ -3,6 +3,8 @@ package domain
import (
"encoding/json"
"time"
"github.com/jackc/pgx/v5/pgtype"
)
type User struct {
@ -29,14 +31,14 @@ type (
CategoryCore
CreatedAt time.Time `json:"createdAt"`
Creator User `json:"creator"`
Notes *string `json:"notes"`
Notes pgtype.Text `json:"notes"`
}
)
type (
FileCore struct {
ID string `json:"id"`
Name *string `json:"name"`
Name pgtype.Text `json:"name"`
MIME MIME `json:"mime"`
}
FileItem struct {
@ -48,7 +50,7 @@ type (
FileCore
CreatedAt time.Time `json:"createdAt"`
Creator User `json:"creator"`
Notes *string `json:"notes"`
Notes pgtype.Text `json:"notes"`
Metadata json.RawMessage `json:"metadata"`
Viewed int `json:"viewed"`
}
@ -58,7 +60,7 @@ type (
TagCore struct {
ID string `json:"id"`
Name string `json:"name"`
Color *string `json:"color"`
Color pgtype.Text `json:"color"`
}
TagItem struct {
TagCore
@ -69,7 +71,7 @@ type (
Category CategoryCore `json:"category"`
CreatedAt time.Time `json:"createdAt"`
Creator User `json:"creator"`
Notes *string `json:"notes"`
Notes pgtype.Text `json:"notes"`
UsedIncl int `json:"usedIncl"`
UsedExcl int `json:"usedExcl"`
}
@ -93,7 +95,7 @@ type (
PoolCore
CreatedAt time.Time `json:"createdAt"`
Creator User `json:"creator"`
Notes *string `json:"notes"`
Notes pgtype.Text `json:"notes"`
Viewed int `json:"viewed"`
}
)

View File

@ -5,7 +5,7 @@ type ErrorCode string
const (
// File errors
ErrFileNotFound ErrorCode = "FILE_NOT_FOUND"
ErrMIMENotSupported ErrorCode = "MIME_NOT_SUPPORTED"
ErrMIMENotSupported ErrorCode = "MIME_NOT_SUPPORTEDF"
// Tag errors
ErrTagNotFound ErrorCode = "TAG_NOT_FOUND"

View File

@ -198,7 +198,8 @@ func (s *FileRepository) Add(ctx context.Context, user_id int, name, mime string
domainErr = domain.NewUnexpectedError(err)
return
}
file.Name = &name
file.Name.String = name
file.Name.Valid = (name != "")
file.MIME.Name = mime
file.MIME.Extension = extension
return