BREAKING CHANGE: V2 of thr SDK #12
30
internal/postgres/post.go
Normal file
30
internal/postgres/post.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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
|
||||||
|
}
|
@ -64,8 +64,7 @@ func (p *postgresqlConnection) AddSource(ctx context.Context, anthroveSource *gr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *postgresqlConnection) AddPost(ctx context.Context, anthrovePost *graphModels.AnthrovePost) error {
|
func (p *postgresqlConnection) AddPost(ctx context.Context, anthrovePost *graphModels.AnthrovePost) error {
|
||||||
//TODO implement me
|
return postgres.CreateAnthrovePostNode(ctx, p.db, anthrovePost.PostID, anthrovePost.Rating)
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *postgresqlConnection) AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *graphModels.AnthroveTag) error {
|
func (p *postgresqlConnection) AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *graphModels.AnthroveTag) error {
|
||||||
|
Reference in New Issue
Block a user