Compare commits

...

3 Commits

Author SHA1 Message Date
a5420cc8c2 feat(pool): added pool pots
All checks were successful
Gitea Build Check / Build (push) Successful in 3m5s
- added basic CRUD for PoolsPosts
2024-10-14 14:16:13 +02:00
c933b2ad63 feat(pool): added pool creation
- added basic CRUD for Pools
2024-10-14 13:05:48 +02:00
9a33de96a0 feat(database): Refactor Pool model to use PoolCategory type for category field 2024-10-14 12:30:27 +02:00
6 changed files with 913 additions and 2 deletions

163
pkg/database/pool.go Normal file
View File

@ -0,0 +1,163 @@
package database
import (
"context"
"errors"
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
log "github.com/sirupsen/logrus"
"go.opentelemetry.io/otel/attribute"
"gorm.io/gorm"
)
func CreatePool(ctx context.Context, pool models.Pool) (models.Pool, error) {
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "CreatePool")
defer span.End()
localLogger = localLogger.WithFields(log.Fields{
"pool_id": pool.ID,
})
span.SetAttributes(
attribute.String("pool_id", string(pool.ID)),
)
utils.HandleEvent(span, localLogger, "Starting pool creation")
if client == nil {
return models.Pool{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
}
result := client.WithContext(ctx).Create(&pool)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.Pool{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DuplicateKey})
}
return models.Pool{}, utils.HandleError(ctx, span, localLogger, result.Error)
}
utils.HandleEvent(span, localLogger, "pool created successfully")
return pool, nil
}
func GetPoolByID(ctx context.Context, id models.PoolID) (models.Pool, error) {
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "GetPool")
defer span.End()
localLogger = localLogger.WithFields(log.Fields{
"pool_id": id,
})
span.SetAttributes(
attribute.String("pool_id", string(id)),
)
utils.HandleEvent(span, localLogger, "Starting get pool by ID")
var pool models.Pool
if client == nil {
return models.Pool{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
}
if len(id) == 0 {
return models.Pool{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PoolIDIsEmpty})
}
result := client.WithContext(ctx).First(&pool, "id = ?", id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return models.Pool{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.NoDataFound})
}
return models.Pool{}, utils.HandleError(ctx, span, localLogger, result.Error)
}
utils.HandleEvent(span, localLogger, "pool retrieved successfully")
return pool, nil
}
// UpdatePool updates the pool information in the database.
// Only supports changing the Name and the Category of the Pool
func UpdatePool(ctx context.Context, pool models.Pool) error {
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "UpdatePool")
defer span.End()
localLogger = localLogger.WithFields(log.Fields{
"pool_id": pool.ID,
})
span.SetAttributes(
attribute.String("pool_id", string(pool.ID)),
)
utils.HandleEvent(span, localLogger, "Starting post update")
if client == nil {
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
}
if len(pool.ID) == 0 {
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PoolIDIsEmpty})
}
updatePost := models.Pool{
BaseModel: models.BaseModel[models.PoolID]{
ID: pool.ID,
},
Name: pool.Name,
Category: pool.Category,
}
result := client.WithContext(ctx).Model(&updatePost).Update("deleted_at", gorm.DeletedAt{})
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.NoDataFound})
}
return utils.HandleError(ctx, span, localLogger, result.Error)
}
utils.HandleEvent(span, localLogger, "pool updated successfully")
return nil
}
func DeletePool(ctx context.Context, id models.PoolID) error {
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "DeletePool")
defer span.End()
localLogger = localLogger.WithFields(log.Fields{
"pool_id": id,
})
span.SetAttributes(
attribute.String("pool_id", string(id)),
)
utils.HandleEvent(span, localLogger, "Starting delete pool")
var pool models.Pool
if client == nil {
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
}
if len(id) == 0 {
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PoolIDIsEmpty})
}
if len(id) != 25 {
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PoolIDToShort})
}
result := client.WithContext(ctx).Delete(&pool, "id = ?", id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.NoDataFound})
}
return utils.HandleError(ctx, span, localLogger, result.Error)
}
utils.HandleEvent(span, localLogger, "pool deleted successfully")
return nil
}

117
pkg/database/pool_post.go Normal file
View File

@ -0,0 +1,117 @@
package database
import (
"context"
"errors"
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
log "github.com/sirupsen/logrus"
"go.opentelemetry.io/otel/attribute"
"gorm.io/gorm"
)
func CreatePoolPost(ctx context.Context, poolID models.PoolID, postID models.PostID, orderPosition int) (models.PoolPost, error) {
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "CreatePoolPost")
defer span.End()
localLogger = localLogger.WithFields(log.Fields{
"pool_id": poolID,
"post_id": postID,
})
span.SetAttributes(
attribute.String("pool_id", string(poolID)),
attribute.String("post_id", string(postID)),
)
utils.HandleEvent(span, localLogger, "Starting poolPost creation")
if client == nil {
return models.PoolPost{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
}
if poolID == "" {
return models.PoolPost{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PoolIDIsEmpty})
}
if len(poolID) != 25 {
return models.PoolPost{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PoolIDToShort})
}
if postID == "" {
return models.PoolPost{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostIDIsEmpty})
}
if len(postID) != 25 {
return models.PoolPost{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostIDToShort})
}
poolPost := models.PoolPost{
PoolID: poolID,
PostID: postID,
OrderPosition: orderPosition,
}
result := client.WithContext(ctx).Create(&poolPost)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.PoolPost{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DuplicateKey})
}
return models.PoolPost{}, utils.HandleError(ctx, span, localLogger, result.Error)
}
utils.HandleEvent(span, localLogger, "poolPost created successfully")
return poolPost, nil
}
func DeletePoolPost(ctx context.Context, poolID models.PoolID, postID models.PostID) error {
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "DeletePoolPost")
defer span.End()
localLogger = localLogger.WithFields(log.Fields{
"pool_id": poolID,
"post_id": postID,
})
span.SetAttributes(
attribute.String("pool_id", string(poolID)),
attribute.String("post_id", string(postID)),
)
utils.HandleEvent(span, localLogger, "Starting delete poolPost")
var poolPost models.PoolPost
if client == nil {
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
}
if poolID == "" {
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PoolIDIsEmpty})
}
if len(poolID) != 25 {
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PoolIDToShort})
}
if postID == "" {
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostIDIsEmpty})
}
if len(postID) != 25 {
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostIDToShort})
}
result := client.WithContext(ctx).Delete(&poolPost, "pool_id = ? AND post_id = ?", poolID, postID)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.NoDataFound})
}
return utils.HandleError(ctx, span, localLogger, result.Error)
}
utils.HandleEvent(span, localLogger, "poolPost deleted successfully")
return nil
}

View File

@ -0,0 +1,252 @@
package database
import (
"context"
"fmt"
"reflect"
"testing"
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
"go.opentelemetry.io/contrib/bridges/otellogrus"
"go.opentelemetry.io/otel"
)
func TestCreatePoolPost(t *testing.T) {
// Setup trow away container
ctx := context.Background()
container, gormDB, err := test.StartPostgresContainer(ctx)
if err != nil {
logger.Fatalf("Could not start PostgreSQL container: %v", err)
}
client = gormDB
// Setup open telemetry
tracer = otel.Tracer(tracingName)
hook := otellogrus.NewHook(tracingName)
logger.AddHook(hook)
defer container.Terminate(ctx)
// -- -- Setup Tests
// -- Create Pool to test with
pool := models.Pool{
BaseModel: models.BaseModel[models.PoolID]{
ID: models.PoolID(fmt.Sprintf("%025s", "Pool1")),
},
Name: "Test Pool 01",
Category: models.Collection,
}
pool, err = CreatePool(ctx, pool)
if err != nil {
logger.Error(err)
}
// -- Create Post to test with
post := models.Post{
BaseModel: models.BaseModel[models.PostID]{
ID: models.PostID(fmt.Sprintf("%025s", "Post1")),
},
Rating: models.SFW,
}
post, err = CreatePost(ctx, post)
if err != nil {
logger.Error(err)
}
// -- Create PoolPost to test with
validPoolPost := models.PoolPost{
PoolID: pool.ID,
PostID: post.ID,
OrderPosition: 0,
}
// --
// -- -- Tests
type args struct {
ctx context.Context
poolID models.PoolID
postID models.PostID
orderPosition int
}
tests := []struct {
name string
args args
want models.PoolPost
wantErr bool
}{
{
name: "Test 01: Valid post & pool ID",
args: args{
ctx: ctx,
postID: post.ID,
poolID: pool.ID,
orderPosition: 0,
},
want: validPoolPost,
wantErr: false,
},
{
name: "Test 02: Duplicate",
args: args{
ctx: ctx,
postID: post.ID,
poolID: pool.ID,
orderPosition: 0,
},
want: models.PoolPost{},
wantErr: true,
},
{
name: "Test 03: poolID is empty",
args: args{
ctx: ctx,
postID: post.ID,
poolID: "",
orderPosition: 0,
},
want: models.PoolPost{},
wantErr: true,
},
{
name: "Test 04: postID name is empty",
args: args{
ctx: ctx,
postID: "",
poolID: pool.ID,
orderPosition: 0,
},
want: models.PoolPost{},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := CreatePoolPost(tt.args.ctx, tt.args.poolID, tt.args.postID, tt.args.orderPosition)
if (err != nil) != tt.wantErr {
t.Errorf("CreatePoolPost() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("CreatePoolPost() got = %v, want %v", got, tt.want)
}
})
}
}
func TestDeletePoolPost(t *testing.T) {
// Setup trow away container
ctx := context.Background()
container, gormDB, err := test.StartPostgresContainer(ctx)
if err != nil {
logger.Fatalf("Could not start PostgreSQL container: %v", err)
}
client = gormDB
// Setup open telemetry
tracer = otel.Tracer(tracingName)
hook := otellogrus.NewHook(tracingName)
logger.AddHook(hook)
defer container.Terminate(ctx)
// -- -- Setup Tests
// -- Create Pool to test with
pool := models.Pool{
BaseModel: models.BaseModel[models.PoolID]{
ID: models.PoolID(fmt.Sprintf("%025s", "Pool1")),
},
Name: "Test Pool 01",
Category: models.Collection,
}
pool, err = CreatePool(ctx, pool)
if err != nil {
logger.Fatal(err)
}
// -- Create Post to test with
post := models.Post{
BaseModel: models.BaseModel[models.PostID]{
ID: models.PostID(fmt.Sprintf("%025s", "Post1")),
},
Rating: models.SFW,
}
post, err = CreatePost(ctx, post)
if err != nil {
logger.Fatal(err)
}
// -- Create PoolPost to test with
validPoolPost := models.PoolPost{
PoolID: pool.ID,
PostID: post.ID,
OrderPosition: 0,
}
validPoolPost, err = CreatePoolPost(ctx, validPoolPost.PoolID, validPoolPost.PostID, validPoolPost.OrderPosition)
if err != nil {
logger.Fatal(err)
}
// --
// -- -- Tests
type args struct {
ctx context.Context
poolID models.PoolID
postID models.PostID
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "Test 01: Valid Post & pool id",
args: args{
ctx: ctx,
poolID: validPoolPost.PoolID,
postID: validPoolPost.PostID,
},
wantErr: false,
},
{
name: "Test 02: Not existing postID",
args: args{
ctx: ctx,
poolID: validPoolPost.PoolID,
postID: "",
},
wantErr: true,
},
{
name: "Test 03: Not existing poolID",
args: args{
ctx: ctx,
poolID: "",
postID: validPoolPost.PostID,
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := DeletePoolPost(tt.args.ctx, tt.args.poolID, tt.args.postID); (err != nil) != tt.wantErr {
t.Errorf("DeletePoolPost() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

369
pkg/database/pool_test.go Normal file
View File

@ -0,0 +1,369 @@
package database
import (
"context"
"fmt"
"reflect"
"testing"
"time"
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
"go.opentelemetry.io/contrib/bridges/otellogrus"
"go.opentelemetry.io/otel"
"gorm.io/gorm"
)
func TestCreatePool(t *testing.T) {
// Setup trow away container
ctx := context.Background()
container, gormDB, err := test.StartPostgresContainer(ctx)
if err != nil {
logger.Fatalf("Could not start PoolgreSQL container: %v", err)
}
client = gormDB
// Setup open telemetry
tracer = otel.Tracer(tracingName)
hook := otellogrus.NewHook(tracingName)
logger.AddHook(hook)
defer container.Terminate(ctx)
// -- -- Setup Tests
// -- Create Pool to test with
validPool := models.Pool{
BaseModel: models.BaseModel[models.PoolID]{
ID: models.PoolID(fmt.Sprintf("%025s", "Pool1")),
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
DeletedAt: gorm.DeletedAt{},
},
Name: "Test Pool 01",
Category: models.Series,
}
// --
// -- -- Tests
type args struct {
ctx context.Context
post models.Pool
}
tests := []struct {
name string
args args
want models.Pool
wantErr bool
}{
{
name: "Test 01: Valid Pool",
args: args{
ctx: ctx,
post: validPool,
},
want: validPool,
wantErr: false,
},
{
name: "Test 02: Duplicate Pool",
args: args{
ctx: ctx,
post: validPool,
},
want: models.Pool{},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := CreatePool(tt.args.ctx, tt.args.post)
if (err != nil) != tt.wantErr {
t.Errorf("CreatePool() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("CreatePool() got = %v, want %v", got, tt.want)
}
})
}
}
func TestGetPoolByID(t *testing.T) {
// Setup trow away container
ctx := context.Background()
container, gormDB, err := test.StartPostgresContainer(ctx)
if err != nil {
logger.Fatalf("Could not start PoolgreSQL container: %v", err)
}
client = gormDB
// Setup open telemetry
tracer = otel.Tracer(tracingName)
hook := otellogrus.NewHook(tracingName)
logger.AddHook(hook)
defer container.Terminate(ctx)
// -- -- Setup Tests
// -- Create Pool to test with
validPool := models.Pool{
BaseModel: models.BaseModel[models.PoolID]{
ID: models.PoolID(fmt.Sprintf("%025s", "Pool1")),
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
DeletedAt: gorm.DeletedAt{},
},
Name: "Test Pool 01",
Category: models.Series,
}
validPool, err = CreatePool(ctx, validPool)
if err != nil {
logger.Fatal(err)
}
// --
// -- -- Tests
type args struct {
ctx context.Context
id models.PoolID
}
tests := []struct {
name string
args args
want models.Pool
wantErr bool
}{
{
name: "Test 01: Valid PoolID",
args: args{
ctx: ctx,
id: validPool.ID,
},
want: validPool,
wantErr: false,
},
{
name: "Test 03: Empty PoolID",
args: args{
ctx: ctx,
id: "",
},
wantErr: true,
},
{
name: "Test 04: Short PoolID",
args: args{
ctx: ctx,
id: "111",
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GetPoolByID(tt.args.ctx, tt.args.id)
if (err != nil) != tt.wantErr {
t.Errorf("GetPoolByID() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !checkPoolID(got, tt.want) {
t.Errorf("GetPoolByID() got = %v, want %v", got, tt.want)
}
})
}
}
func TestUpdatePool(t *testing.T) {
// Setup trow away container
ctx := context.Background()
container, gormDB, err := test.StartPostgresContainer(ctx)
if err != nil {
logger.Fatalf("Could not start PoolgreSQL container: %v", err)
}
client = gormDB
// Setup open telemetry
tracer = otel.Tracer(tracingName)
hook := otellogrus.NewHook(tracingName)
logger.AddHook(hook)
defer container.Terminate(ctx)
// -- -- Setup Tests
// -- Create Pool to test with
validPool := models.Pool{
BaseModel: models.BaseModel[models.PoolID]{
ID: models.PoolID(fmt.Sprintf("%025s", "Pool1")),
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
DeletedAt: gorm.DeletedAt{},
},
Name: "Test Pool 01",
Category: models.Series,
}
validPool, err = CreatePool(ctx, validPool)
if err != nil {
logger.Fatal(err)
}
// --
// -- Create Updates models for Pool
validUpdatePool := validPool
validUpdatePool.Name = "Updated Test Pool"
validUpdatePool.Category = models.Collection
invalidUpdatePool := models.Pool{}
// --
// -- -- Tests
type args struct {
ctx context.Context
anthrovePool models.Pool
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "Test 01: Valid Update for Pool",
args: args{
ctx: ctx,
anthrovePool: validUpdatePool,
},
wantErr: false,
},
{
name: "Test 02: Invalid Update for Pool",
args: args{
ctx: ctx,
anthrovePool: invalidUpdatePool,
},
wantErr: true,
},
{
name: "Test 03: Empty ID for Update for Pool",
args: args{
ctx: ctx,
anthrovePool: models.Pool{BaseModel: models.BaseModel[models.PoolID]{ID: ""}},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := UpdatePool(tt.args.ctx, tt.args.anthrovePool); (err != nil) != tt.wantErr {
t.Errorf("UpdatePool() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestDeletePool(t *testing.T) {
// Setup trow away container
ctx := context.Background()
container, gormDB, err := test.StartPostgresContainer(ctx)
if err != nil {
logger.Fatalf("Could not start PoolgreSQL container: %v", err)
}
client = gormDB
// Setup open telemetry
tracer = otel.Tracer(tracingName)
hook := otellogrus.NewHook(tracingName)
logger.AddHook(hook)
defer container.Terminate(ctx)
// -- -- Setup Tests
// -- Create Pool to test with
validPool := models.Pool{
BaseModel: models.BaseModel[models.PoolID]{
ID: models.PoolID(fmt.Sprintf("%025s", "Pool1")),
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
DeletedAt: gorm.DeletedAt{},
},
Name: "Test Pool 01",
Category: models.Series,
}
validPool, err = CreatePool(ctx, validPool)
if err != nil {
logger.Fatal(err)
}
// --
// -- -- Tests
type args struct {
ctx context.Context
id models.PoolID
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "Test 01: Delete Valid Pool",
args: args{
ctx: ctx,
id: validPool.ID,
},
wantErr: false,
},
{
name: "Test 02: Delete not existed Pool",
args: args{
ctx: ctx,
id: validPool.ID,
},
wantErr: false,
},
{
name: "Test 03: Empty PoolID",
args: args{
ctx: ctx,
id: "",
},
wantErr: true,
},
{
name: "Test 04: Short PoolID",
args: args{
ctx: ctx,
id: "111",
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := DeletePool(tt.args.ctx, tt.args.id); (err != nil) != tt.wantErr {
t.Errorf("DeletePool() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func checkPoolID(got models.Pool, want models.Pool) bool {
if got.ID != want.ID {
return false
}
return true
}

View File

@ -30,6 +30,9 @@ const (
PostIDToShort = "PostID needs to be 25 characters long"
BatchSizeIsEmpty = "batchSize cannot be empty"
PoolIDIsEmpty = "PoolID cannot be empty"
PoolIDToShort = "PoolID needs to be 25 characters long"
)
type EntityValidationFailed struct {

View File

@ -1,9 +1,16 @@
package models
type PoolCategory string
const (
Series PoolCategory = "series"
Collection PoolCategory = "collection"
)
type Pool struct {
BaseModel[PoolID]
Name string `json:"name" gorm:"type:varchar(25)"`
Category string `json:"category" gorm:"type:pool_category;type:enum('series', 'collection')"`
Name string `json:"name" gorm:"type:varchar(25)"`
Category PoolCategory `json:"category" gorm:"type:pool_category;type:enum('series', 'collection')"`
}
func (Pool) TableName() string {