31 lines
721 B
Go
31 lines
721 B
Go
|
package postgres
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/pgModels"
|
||
|
log "github.com/sirupsen/logrus"
|
||
|
"gorm.io/gorm"
|
||
|
)
|
||
|
|
||
|
func CreateAnthrovePostNode(ctx context.Context, db *gorm.DB, anthrovePostID models.AnthrovePostID, anthroveRating models.Rating) error {
|
||
|
post := pgModels.Post{
|
||
|
BaseModel: pgModels.BaseModel{
|
||
|
ID: string(anthrovePostID),
|
||
|
},
|
||
|
Rating: anthroveRating,
|
||
|
}
|
||
|
|
||
|
err := db.WithContext(ctx).Create(&post).Error
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
log.WithFields(log.Fields{
|
||
|
"anthrove_post_id": anthrovePostID,
|
||
|
"anthrove_post_rating": anthroveRating,
|
||
|
}).Trace("database: created anthrove post")
|
||
|
|
||
|
return nil
|
||
|
}
|