30 lines
778 B
Go
30 lines
778 B
Go
package database
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
"git.jmbit.de/jmb/scanfile/server/internal/sqlc"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
func GetFileByID(fileID string) (sqlc.File, error) {
|
|
var pgUUID pgtype.UUID
|
|
err := pgUUID.Scan(fileID)
|
|
if err != nil {
|
|
slog.Error("Unable to convert string to UUID", "file-uuid", fileID, "error", err)
|
|
}
|
|
query := sqlc.New(pool)
|
|
file, err := query.GetFileByUUID(context.Background(), pgUUID)
|
|
|
|
return file, nil
|
|
}
|
|
|
|
func InsertFileProperties(properties sqlc.InsertFilePropertiesParams) error {
|
|
query := sqlc.New(pool)
|
|
err := query.InsertFileProperties(context.Background(), properties)
|
|
if err != nil {
|
|
slog.Error("Unable to add file properties", "file-uuid", properties.ID.String(), "error", err)
|
|
}
|
|
return err
|
|
}
|