BREAKING CHANGE: V2 of thr SDK #12

Merged
fenpaws merged 124 commits from develop/postgresql into main 2024-07-01 20:46:28 +00:00
7 changed files with 80 additions and 80 deletions
Showing only changes of commit 6e3edfc1fa - Show all commits

View File

@ -4,7 +4,7 @@ import (
"context"
"errors"
errors2 "git.dragse.it/anthrove/otter-space-sdk/pkg/errors"
otterError "git.dragse.it/anthrove/otter-space-sdk/pkg/error"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
log "github.com/sirupsen/logrus"
@ -14,19 +14,19 @@ import (
func CreatePost(ctx context.Context, db *gorm.DB, anthrovePost *models.Post) error {
if anthrovePost == nil {
return &errors2.EntityValidationFailed{Reason: "anthrovePost is nil"}
return &otterError.EntityValidationFailed{Reason: "anthrovePost is nil"}
}
result := db.WithContext(ctx).Create(&anthrovePost)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &errors2.EntityAlreadyExists{}
return &otterError.EntityAlreadyExists{}
}
return result.Error
}
if result.RowsAffected == 0 {
return &errors2.NoDataWritten{}
return &otterError.NoDataWritten{}
}
log.WithFields(log.Fields{
@ -40,18 +40,18 @@ func CreatePost(ctx context.Context, db *gorm.DB, anthrovePost *models.Post) err
func GetPostByAnthroveID(ctx context.Context, db *gorm.DB, anthrovePostID models.AnthrovePostID) (*models.Post, error) {
if anthrovePostID == "" {
return nil, &errors2.EntityValidationFailed{Reason: "anthrovePostID is not set"}
return nil, &otterError.EntityValidationFailed{Reason: "anthrovePostID is not set"}
}
if len(anthrovePostID) != 25 {
return nil, &errors2.EntityValidationFailed{Reason: "anthrovePostID needs to be 25 characters long"}
return nil, &otterError.EntityValidationFailed{Reason: "anthrovePostID needs to be 25 characters long"}
}
var post models.Post
result := db.WithContext(ctx).First(&post, "id = ?", anthrovePostID)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -62,7 +62,7 @@ func GetPostByAnthroveID(ctx context.Context, db *gorm.DB, anthrovePostID models
func GetPostByURL(ctx context.Context, db *gorm.DB, sourceURL string) (*models.Post, error) {
if sourceURL == "" {
return nil, &errors2.EntityValidationFailed{Reason: "sourceURL is not set"}
return nil, &otterError.EntityValidationFailed{Reason: "sourceURL is not set"}
}
var post models.Post
@ -70,7 +70,7 @@ func GetPostByURL(ctx context.Context, db *gorm.DB, sourceURL string) (*models.P
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -81,7 +81,7 @@ func GetPostByURL(ctx context.Context, db *gorm.DB, sourceURL string) (*models.P
func GetPostBySourceID(ctx context.Context, db *gorm.DB, sourceID models.AnthroveSourceID) (*models.Post, error) {
if sourceID == "" {
return nil, &errors2.EntityValidationFailed{Reason: "sourceID is not set"}
return nil, &otterError.EntityValidationFailed{Reason: "sourceID is not set"}
}
var post models.Post
@ -89,7 +89,7 @@ func GetPostBySourceID(ctx context.Context, db *gorm.DB, sourceID models.Anthrov
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}

View File

@ -4,7 +4,7 @@ import (
"context"
"errors"
errors2 "git.dragse.it/anthrove/otter-space-sdk/pkg/errors"
otterError "git.dragse.it/anthrove/otter-space-sdk/pkg/error"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
log "github.com/sirupsen/logrus"
"gorm.io/gorm"
@ -14,22 +14,22 @@ func CreateReferenceBetweenPostAndSource(ctx context.Context, db *gorm.DB, anthr
var source models.Source
if anthrovePostID == "" {
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthrovePostID) != 25 {
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
if sourceDomain == "" {
return &errors2.EntityValidationFailed{Reason: "sourceDomain cannot be empty"}
return &otterError.EntityValidationFailed{Reason: "sourceDomain cannot be empty"}
}
// Find the source
result := db.WithContext(ctx).Where("domain = ?", sourceDomain).First(&source)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &errors2.NoDataFound{}
return &otterError.NoDataFound{}
}
return result.Error
}
@ -43,13 +43,13 @@ func CreateReferenceBetweenPostAndSource(ctx context.Context, db *gorm.DB, anthr
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &errors2.EntityAlreadyExists{}
return &otterError.EntityAlreadyExists{}
}
return result.Error
}
if result.RowsAffected == 0 {
return &errors2.NoDataWritten{}
return &otterError.NoDataWritten{}
}
log.WithFields(log.Fields{
@ -63,15 +63,15 @@ func CreateReferenceBetweenPostAndSource(ctx context.Context, db *gorm.DB, anthr
func CreateReferenceBetweenUserAndPost(ctx context.Context, db *gorm.DB, anthroveUserID models.AnthroveUserID, anthrovePostID models.AnthrovePostID) error {
if anthrovePostID == "" {
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthrovePostID) != 25 {
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
if anthroveUserID == "" {
return &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
return &otterError.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
}
userFavorite := models.UserFavorites{
@ -82,13 +82,13 @@ func CreateReferenceBetweenUserAndPost(ctx context.Context, db *gorm.DB, anthrov
result := db.WithContext(ctx).Create(&userFavorite)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &errors2.EntityAlreadyExists{}
return &otterError.EntityAlreadyExists{}
}
return result.Error
}
if result.RowsAffected == 0 {
return &errors2.NoDataWritten{}
return &otterError.NoDataWritten{}
}
log.WithFields(log.Fields{
@ -103,25 +103,25 @@ func CheckReferenceBetweenUserAndPost(ctx context.Context, db *gorm.DB, anthrove
var count int64
if anthrovePostID == "" {
return false, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return false, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthrovePostID) != 25 {
return false, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return false, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
if anthroveUserID == "" {
return false, &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
return false, &otterError.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
}
if len(anthroveUserID) != 25 {
return false, &errors2.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
return false, &otterError.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
}
result := db.WithContext(ctx).Model(&models.UserFavorites{}).Where("user_id = ? AND post_id = ?", string(anthroveUserID), string(anthrovePostID)).Count(&count)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return false, &errors2.NoDataFound{}
return false, &otterError.NoDataFound{}
}
return false, result.Error
}

View File

@ -4,7 +4,7 @@ import (
"context"
"errors"
errors2 "git.dragse.it/anthrove/otter-space-sdk/pkg/errors"
otterError "git.dragse.it/anthrove/otter-space-sdk/pkg/error"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
log "github.com/sirupsen/logrus"
@ -15,20 +15,20 @@ import (
func CreateSource(ctx context.Context, db *gorm.DB, anthroveSource *models.Source) error {
if anthroveSource.Domain == "" {
return &errors2.EntityValidationFailed{Reason: "Domain is required"}
return &otterError.EntityValidationFailed{Reason: "Domain is required"}
}
result := db.WithContext(ctx).Where(models.Source{Domain: anthroveSource.Domain}).FirstOrCreate(anthroveSource)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &errors2.EntityAlreadyExists{}
return &otterError.EntityAlreadyExists{}
}
return result.Error
}
if result.RowsAffected == 0 {
return &errors2.NoDataWritten{}
return &otterError.NoDataWritten{}
}
log.WithFields(log.Fields{
@ -48,7 +48,7 @@ func GetAllSource(ctx context.Context, db *gorm.DB) ([]models.Source, error) {
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -65,14 +65,14 @@ func GetSourceByDomain(ctx context.Context, db *gorm.DB, sourceDomain models.Ant
var sources models.Source
if sourceDomain == "" {
return nil, &errors2.EntityValidationFailed{Reason: "AnthroveSourceDomain is not set"}
return nil, &otterError.EntityValidationFailed{Reason: "AnthroveSourceDomain is not set"}
}
result := db.WithContext(ctx).Where("domain = ?", sourceDomain).First(&sources)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}

View File

@ -4,7 +4,7 @@ import (
"context"
"errors"
errors2 "git.dragse.it/anthrove/otter-space-sdk/pkg/errors"
otterError "git.dragse.it/anthrove/otter-space-sdk/pkg/error"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
log "github.com/sirupsen/logrus"
"gorm.io/gorm"
@ -13,19 +13,19 @@ import (
func CreateTag(ctx context.Context, db *gorm.DB, tag *models.Tag) error {
if tag == nil {
return &errors2.EntityValidationFailed{Reason: "Tag is nil"}
return &otterError.EntityValidationFailed{Reason: "Tag is nil"}
}
result := db.WithContext(ctx).Where(tag).Create(tag)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &errors2.EntityAlreadyExists{}
return &otterError.EntityAlreadyExists{}
}
return result.Error
}
if result.RowsAffected == 0 {
return &errors2.NoDataWritten{}
return &otterError.NoDataWritten{}
}
log.WithFields(log.Fields{
@ -39,15 +39,15 @@ func CreateTag(ctx context.Context, db *gorm.DB, tag *models.Tag) error {
func CreateTagAndReferenceToPost(ctx context.Context, db *gorm.DB, anthrovePostID models.AnthrovePostID, tag *models.Tag) error {
if anthrovePostID == "" {
return &errors2.EntityValidationFailed{Reason: "anthrovePostID cannot be empty"}
return &otterError.EntityValidationFailed{Reason: "anthrovePostID cannot be empty"}
}
if len(anthrovePostID) != 25 {
return &errors2.EntityValidationFailed{Reason: "anthrovePostID needs to be 25 characters long"}
return &otterError.EntityValidationFailed{Reason: "anthrovePostID needs to be 25 characters long"}
}
if tag == nil {
return &errors2.EntityValidationFailed{Reason: "Tag is nil"}
return &otterError.EntityValidationFailed{Reason: "Tag is nil"}
}
pgPost := models.Post{
@ -59,9 +59,9 @@ func CreateTagAndReferenceToPost(ctx context.Context, db *gorm.DB, anthrovePostI
err := db.WithContext(ctx).Model(&pgPost).Association("Tags").Append(tag)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return &errors2.NoDataFound{}
return &otterError.NoDataFound{}
}
return errors.Join(err, &errors2.NoRelationCreated{})
return errors.Join(err, &otterError.NoRelationCreated{})
}
log.WithFields(log.Fields{
@ -80,7 +80,7 @@ func GetTags(ctx context.Context, db *gorm.DB) ([]models.Tag, error) {
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}

View File

@ -4,7 +4,7 @@ import (
"context"
"errors"
errors2 "git.dragse.it/anthrove/otter-space-sdk/pkg/errors"
otterError "git.dragse.it/anthrove/otter-space-sdk/pkg/error"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
log "github.com/sirupsen/logrus"
"gorm.io/gorm"
@ -13,11 +13,11 @@ import (
func CreateUser(ctx context.Context, db *gorm.DB, anthroveUserID models.AnthroveUserID) error {
if anthroveUserID == "" {
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthroveUserID) != 25 {
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
user := models.User{
@ -29,7 +29,7 @@ func CreateUser(ctx context.Context, db *gorm.DB, anthroveUserID models.Anthrove
result := db.WithContext(ctx).FirstOrCreate(&user)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &errors2.EntityAlreadyExists{}
return &otterError.EntityAlreadyExists{}
}
return result.Error
}
@ -40,19 +40,19 @@ func CreateUser(ctx context.Context, db *gorm.DB, anthroveUserID models.Anthrove
func CreateUserWithRelationToSource(ctx context.Context, db *gorm.DB, anthroveUserID models.AnthroveUserID, sourceID models.AnthroveSourceID, accountId string, accountUsername string) error {
if anthroveUserID == "" {
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthroveUserID) != 25 {
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
if accountId == "" {
return &errors2.EntityValidationFailed{Reason: "accountID cannot be empty"}
return &otterError.EntityValidationFailed{Reason: "accountID cannot be empty"}
}
if accountUsername == "" {
return &errors2.EntityValidationFailed{Reason: "accountUsername cannot be empty"}
return &otterError.EntityValidationFailed{Reason: "accountUsername cannot be empty"}
}
err := CreateUser(ctx, db, anthroveUserID)
@ -67,7 +67,7 @@ func CreateUserWithRelationToSource(ctx context.Context, db *gorm.DB, anthroveUs
result := db.WithContext(ctx).Where(&source).First(&source)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &errors2.NoDataFound{}
return &otterError.NoDataFound{}
}
return result.Error
}
@ -82,11 +82,11 @@ func CreateUserWithRelationToSource(ctx context.Context, db *gorm.DB, anthroveUs
result = db.WithContext(ctx).FirstOrCreate(&userSource)
if result.Error != nil {
return errors.Join(result.Error, &errors2.NoRelationCreated{})
return errors.Join(result.Error, &otterError.NoRelationCreated{})
}
if result.RowsAffected == 0 {
return &errors2.NoDataWritten{}
return &otterError.NoDataWritten{}
}
log.WithFields(log.Fields{
@ -103,17 +103,17 @@ func GetUserFavoritesCount(ctx context.Context, db *gorm.DB, anthroveUserID mode
var count int64
if anthroveUserID == "" {
return 0, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return 0, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthroveUserID) != 25 {
return 0, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return 0, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
result := db.WithContext(ctx).Model(&models.UserFavorites{}).Where("user_id = ?", string(anthroveUserID)).Count(&count)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return 0, &errors2.NoDataFound{}
return 0, &otterError.NoDataFound{}
}
return 0, result.Error
}
@ -131,17 +131,17 @@ func GetUserSourceLinks(ctx context.Context, db *gorm.DB, anthroveUserID models.
userSourceMap := make(map[string]models.UserSource)
if anthroveUserID == "" {
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return nil, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthroveUserID) != 25 {
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return nil, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
result := db.WithContext(ctx).Model(&models.UserSource{}).Where("user_id = ?", string(anthroveUserID)).Find(&userSources)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -151,7 +151,7 @@ func GetUserSourceLinks(ctx context.Context, db *gorm.DB, anthroveUserID models.
result = db.WithContext(ctx).Model(&models.Source{}).Where("id = ?", userSource.SourceID).First(&source)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -179,25 +179,25 @@ func GetUserSourceBySourceID(ctx context.Context, db *gorm.DB, anthroveUserID mo
userSourceMap := make(map[string]models.UserSource)
if anthroveUserID == "" {
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return nil, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthroveUserID) != 25 {
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return nil, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
if sourceID == "" {
return nil, &errors2.EntityValidationFailed{Reason: "sourceID cannot be empty"}
return nil, &otterError.EntityValidationFailed{Reason: "sourceID cannot be empty"}
}
if len(sourceID) != 25 {
return nil, &errors2.EntityValidationFailed{Reason: "sourceID needs to be 25 characters long"}
return nil, &otterError.EntityValidationFailed{Reason: "sourceID needs to be 25 characters long"}
}
result := db.WithContext(ctx).Model(&models.UserSource{}).InnerJoins("Source", db.Where("id = ?", sourceID)).Where("user_id = ?", string(anthroveUserID)).First(&userSources)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -207,7 +207,7 @@ func GetUserSourceBySourceID(ctx context.Context, db *gorm.DB, anthroveUserID mo
result = db.WithContext(ctx).Model(&models.Source{}).Where("id = ?", userSource.SourceID).First(&source)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -238,7 +238,7 @@ func GetAllAnthroveUserIDs(ctx context.Context, db *gorm.DB) ([]models.AnthroveU
result := db.WithContext(ctx).Model(&models.User{}).Find(&users)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -259,17 +259,17 @@ func GetUserFavoriteWithPagination(ctx context.Context, db *gorm.DB, anthroveUse
var favoritePosts []models.Post
if anthroveUserID == "" {
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return nil, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthroveUserID) != 25 {
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return nil, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
err := db.WithContext(ctx).Model(&models.UserFavorites{}).Where("user_id = ?", string(anthroveUserID)).Offset(skip).Limit(limit).Find(&userFavorites).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, err
}
@ -279,7 +279,7 @@ func GetUserFavoriteWithPagination(ctx context.Context, db *gorm.DB, anthroveUse
err = db.WithContext(ctx).Model(&models.Post{}).Where("id = ?", userFavorite.PostID).First(&post).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, err
}
@ -303,17 +303,17 @@ func GetUserTagWitRelationToFavedPosts(ctx context.Context, db *gorm.DB, anthrov
var userFavorites []models.UserFavorites
if anthroveUserID == "" {
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
return nil, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDIsEmpty}
}
if len(anthroveUserID) != 25 {
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
return nil, &otterError.EntityValidationFailed{Reason: otterError.AnthroveUserIDToShort}
}
result := db.WithContext(ctx).Where("user_id = ?", string(anthroveUserID)).Find(&userFavorites)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}
@ -328,7 +328,7 @@ func GetUserTagWitRelationToFavedPosts(ctx context.Context, db *gorm.DB, anthrov
result = db.WithContext(ctx).Preload("Tags").First(&post, "id = ?", userFavorite.PostID)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, &errors2.NoDataFound{}
return nil, &otterError.NoDataFound{}
}
return nil, result.Error
}

View File

@ -1,4 +1,4 @@
package errors
package error
type EntityAlreadyExists struct{}

View File

@ -1,4 +1,4 @@
package errors
package error
import "fmt"