refactor(backend/models): use pgtype for nullable fields
This commit is contained in:
parent
59eacd6bc5
commit
761babfa1a
@ -1,71 +1,75 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
Name string `json:"name"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
}
|
||||
|
||||
type MIME struct {
|
||||
Name string `json:"name"`
|
||||
Extension string `json:"extension"`
|
||||
}
|
||||
|
||||
type Category struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Creator User `json:"creator"`
|
||||
}
|
||||
|
||||
type File struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
MIME MIME `json:"mime"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Creator User `json:"creator"`
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
Category Category `json:"category"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Creator User `json:"creator"`
|
||||
}
|
||||
|
||||
type Autotag struct {
|
||||
TriggerTag Tag `json:"trigger_tag"`
|
||||
AddTag Tag `json:"add_tag"`
|
||||
IsActive bool `json:"is_active"`
|
||||
}
|
||||
|
||||
type Pool struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Creator User `json:"creator"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID int `json:"id"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
LastActivity time.Time `json:"last_activity"`
|
||||
}
|
||||
|
||||
type Pagination struct {
|
||||
Total int `json:"total"`
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type Slice[T any] struct {
|
||||
Pagination Pagination `json:"pagination"`
|
||||
Data []T `json:"data"`
|
||||
}
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Name string `json:"name"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
}
|
||||
|
||||
type MIME struct {
|
||||
Name string `json:"name"`
|
||||
Extension string `json:"extension"`
|
||||
}
|
||||
|
||||
type Category struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Color pgtype.Text `json:"color"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Creator User `json:"creator"`
|
||||
}
|
||||
|
||||
type File struct {
|
||||
ID string `json:"id"`
|
||||
Name pgtype.Text `json:"name"`
|
||||
MIME MIME `json:"mime"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Creator User `json:"creator"`
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Color pgtype.Text `json:"color"`
|
||||
Category Category `json:"category"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Creator User `json:"creator"`
|
||||
}
|
||||
|
||||
type Autotag struct {
|
||||
TriggerTag Tag `json:"trigger_tag"`
|
||||
AddTag Tag `json:"add_tag"`
|
||||
IsActive bool `json:"is_active"`
|
||||
}
|
||||
|
||||
type Pool struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Creator User `json:"creator"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID int `json:"id"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
LastActivity time.Time `json:"last_activity"`
|
||||
}
|
||||
|
||||
type Pagination struct {
|
||||
Total int `json:"total"`
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type Slice[T any] struct {
|
||||
Pagination Pagination `json:"pagination"`
|
||||
Data []T `json:"data"`
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user