Compare commits

..

2 Commits

Author SHA1 Message Date
53e1412772 fix: model to be primaryKey
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-07-05 14:07:56 +02:00
ad9124ef41 fix: reverse validation
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-07-05 14:06:39 +02:00
2 changed files with 6 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package postgres
import (
"context"
"errors"
otterError "git.dragse.it/anthrove/otter-space-sdk/v2/pkg/error"
"git.dragse.it/anthrove/otter-space-sdk/v2/pkg/models"
@ -38,14 +39,14 @@ func CreatePost(ctx context.Context, db *gorm.DB, anthrovePost *models.Post) err
// TODO: Make Tests
func CreatePostInBatch(ctx context.Context, db *gorm.DB, anthrovePost []models.Post, batchSize int) error {
if len(anthrovePost) == 0 {
return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be empty"}
}
if anthrovePost == nil {
return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be nil"}
}
if len(anthrovePost) == 0 {
return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be empty"}
}
if batchSize == 0 {
return &otterError.EntityValidationFailed{Reason: "batch size cannot be zero"}
}

View File

@ -3,7 +3,7 @@ package models
type PostReference struct {
PostID string `gorm:"primaryKey"`
SourceID string `gorm:"primaryKey"`
URL string `gorm:"not null;unique"`
URL string `gorm:"primaryKey"`
PostReferenceConfig
}