BREAKING CHANGE: V2 of thr SDK #12
22
README.md
22
README.md
@ -17,20 +17,20 @@ Here's a simple usage example:
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/graph"
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/database"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
client := graph.NewGraphConnection()
|
client := graph.NewGraphConnection()
|
||||||
err := client.Connect(context.Background(), "your-endpoint", "your-username", "your-password")
|
err := client.Connect(context.Background(), "your-endpoint", "your-username", "your-password")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// further usage of the client...
|
// further usage of the client...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
7
go.mod
7
go.mod
@ -7,4 +7,9 @@ require (
|
|||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
require (
|
||||||
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||||
|
gorm.io/gorm v1.25.10 // indirect
|
||||||
|
)
|
||||||
|
6
go.sum
6
go.sum
@ -1,6 +1,10 @@
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/neo4j/neo4j-go-driver/v5 v5.17.0 h1:Bdqg1Y8Hd3uLYToXtBjysDYXTdMiP7zeUNUEwfbJkSo=
|
github.com/neo4j/neo4j-go-driver/v5 v5.17.0 h1:Bdqg1Y8Hd3uLYToXtBjysDYXTdMiP7zeUNUEwfbJkSo=
|
||||||
github.com/neo4j/neo4j-go-driver/v5 v5.17.0/go.mod h1:Vff8OwT7QpLm7L2yYr85XNWe9Rbqlbeb9asNXJTHO4k=
|
github.com/neo4j/neo4j-go-driver/v5 v5.17.0/go.mod h1:Vff8OwT7QpLm7L2yYr85XNWe9Rbqlbeb9asNXJTHO4k=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@ -15,3 +19,5 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s=
|
||||||
|
gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||||
|
@ -19,21 +19,21 @@ func (n graphLogger) Error(name string, id string, err error) {
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"name": name,
|
"name": name,
|
||||||
"id": id,
|
"id": id,
|
||||||
}).Errorf("graph: %s", err)
|
}).Errorf("database: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n graphLogger) Warnf(name string, id string, msg string, args ...any) {
|
func (n graphLogger) Warnf(name string, id string, msg string, args ...any) {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"name": name,
|
"name": name,
|
||||||
"id": id,
|
"id": id,
|
||||||
}).Warnf("graph: %v", fmt.Sprintf(msg, args...))
|
}).Warnf("database: %v", fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n graphLogger) Infof(name string, id string, msg string, args ...any) {
|
func (n graphLogger) Infof(name string, id string, msg string, args ...any) {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"name": name,
|
"name": name,
|
||||||
"id": id,
|
"id": id,
|
||||||
}).Infof("graph: %v", fmt.Sprintf(msg, args...))
|
}).Infof("database: %v", fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n graphLogger) Debugf(name string, id string, msg string, args ...any) {
|
func (n graphLogger) Debugf(name string, id string, msg string, args ...any) {
|
||||||
@ -41,6 +41,6 @@ func (n graphLogger) Debugf(name string, id string, msg string, args ...any) {
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"name": name,
|
"name": name,
|
||||||
"id": id,
|
"id": id,
|
||||||
}).Debugf("graph: %v", fmt.Sprintf(msg, args...))
|
}).Debugf("database: %v", fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func CreateAnthrovePostNode(ctx context.Context, driver neo4j.DriverWithContext,
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_post_id": anthrovePost.PostID,
|
"anthrove_post_id": anthrovePost.PostID,
|
||||||
"anthrove_post_rating": anthrovePost.Rating,
|
"anthrove_post_rating": anthrovePost.Rating,
|
||||||
}).Trace("graph: created anthrove post")
|
}).Trace("database: created anthrove post")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ func executeCheckQuery(ctx context.Context, driver neo4j.DriverWithContext, quer
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_post_id": anthrovePost.PostID,
|
"anthrove_post_id": anthrovePost.PostID,
|
||||||
"anthrove_post_exists": exists,
|
"anthrove_post_exists": exists,
|
||||||
}).Trace("graph: checked if post exists")
|
}).Trace("database: checked if post exists")
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, exists, nil
|
return nil, exists, nil
|
||||||
|
@ -33,7 +33,7 @@ func EstablishAnthrovePostToSourceLink(ctx context.Context, driver neo4j.DriverW
|
|||||||
"anthrove_post_id": anthrovePostID,
|
"anthrove_post_id": anthrovePostID,
|
||||||
"source_post_url": anthrovePostRelationship.Url,
|
"source_post_url": anthrovePostRelationship.Url,
|
||||||
"source_post_id": anthrovePostRelationship.PostID,
|
"source_post_id": anthrovePostRelationship.PostID,
|
||||||
}).Trace("graph: creating anthrove post to source link")
|
}).Trace("database: creating anthrove post to source link")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ func EstablishUserToPostLink(ctx context.Context, driver neo4j.DriverWithContext
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_post_id": anthrovePost.PostID,
|
"anthrove_post_id": anthrovePost.PostID,
|
||||||
"anthrove_user_id": anthroveUser.UserID,
|
"anthrove_user_id": anthroveUser.UserID,
|
||||||
}).Trace("graph: created user to post link")
|
}).Trace("database: created user to post link")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ func CheckUserToPostLink(ctx context.Context, driver neo4j.DriverWithContext, an
|
|||||||
"relationship_exists": exists,
|
"relationship_exists": exists,
|
||||||
"relationship_anthrove_user_id": anthroveUserID,
|
"relationship_anthrove_user_id": anthroveUserID,
|
||||||
"relationship_e621_post_id": "",
|
"relationship_e621_post_id": "",
|
||||||
}).Trace("graph: checked user post relationship")
|
}).Trace("database: checked user post relationship")
|
||||||
|
|
||||||
return exists, nil
|
return exists, nil
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,14 @@ func CreateSourceNode(ctx context.Context, driver neo4j.DriverWithContext, anthr
|
|||||||
|
|
||||||
_, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
|
_, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("graph: %w", err)
|
return fmt.Errorf("database: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"node_source_url": anthroveSource.Domain,
|
"node_source_url": anthroveSource.Domain,
|
||||||
"node_source_displayName": anthroveSource.DisplayName,
|
"node_source_displayName": anthroveSource.DisplayName,
|
||||||
"node_source_icon": anthroveSource.Icon,
|
"node_source_icon": anthroveSource.Icon,
|
||||||
}).Trace("graph: created source node")
|
}).Trace("database: created source node")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]m
|
|||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"tag_amount": len(sources),
|
"tag_amount": len(sources),
|
||||||
}).Trace("graph: created tag node")
|
}).Trace("database: created tag node")
|
||||||
|
|
||||||
return sources, nil
|
return sources, nil
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ func GetSourceNodesByURL(ctx context.Context, driver neo4j.DriverWithContext, so
|
|||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"source_url": sourceUrl,
|
"source_url": sourceUrl,
|
||||||
}).Trace("graph: got source node")
|
}).Trace("database: got source node")
|
||||||
|
|
||||||
return &source, nil
|
return &source, nil
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ func CreateTagNodeWitRelation(ctx context.Context, driver neo4j.DriverWithContex
|
|||||||
"anthrove_post_id": anthrovePostID,
|
"anthrove_post_id": anthrovePostID,
|
||||||
"tag_name": anthroveTag.Name,
|
"tag_name": anthroveTag.Name,
|
||||||
"tag_type": anthroveTag.Type,
|
"tag_type": anthroveTag.Type,
|
||||||
}).Trace("graph: created tag node")
|
}).Trace("database: created tag node")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ func GetTags(ctx context.Context, driver neo4j.DriverWithContext) ([]models.Tags
|
|||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"tag_amount": len(userTags),
|
"tag_amount": len(userTags),
|
||||||
}).Trace("graph: created tag node")
|
}).Trace("database: created tag node")
|
||||||
|
|
||||||
return userTags, nil
|
return userTags, nil
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func CreateUserNodeWithSourceRelation(ctx context.Context, driver neo4j.DriverWi
|
|||||||
"source_user_id": userID,
|
"source_user_id": userID,
|
||||||
"source_user_name": username,
|
"source_user_name": username,
|
||||||
"source_domain": sourceDomain,
|
"source_domain": sourceDomain,
|
||||||
}).Trace("graph: crated user with relationship")
|
}).Trace("database: crated user with relationship")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ func GetUserFavoritesCount(ctx context.Context, driver neo4j.DriverWithContext,
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_user_id": anthroveUserID,
|
"anthrove_user_id": anthroveUserID,
|
||||||
"anthrove_user_fav_count": userFavoriteCount,
|
"anthrove_user_fav_count": userFavoriteCount,
|
||||||
}).Trace("graph: got user favorite count")
|
}).Trace("database: got user favorite count")
|
||||||
|
|
||||||
return userFavoriteCount, nil
|
return userFavoriteCount, nil
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anth
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_user_id": anthroveUserID,
|
"anthrove_user_id": anthroveUserID,
|
||||||
"anthrove_data": userSource,
|
"anthrove_data": userSource,
|
||||||
}).Trace("graph: got user favorite count")
|
}).Trace("database: got user favorite count")
|
||||||
|
|
||||||
return userSource, nil
|
return userSource, nil
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ func GetSpecifiedUserSourceLink(ctx context.Context, driver neo4j.DriverWithCont
|
|||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_user_id": anthroveUserID,
|
"anthrove_user_id": anthroveUserID,
|
||||||
"anthrove_data": userSource,
|
"anthrove_data": userSource,
|
||||||
}).Trace("graph: got user favorite count")
|
}).Trace("database: got user favorite count")
|
||||||
|
|
||||||
return userSource, nil
|
return userSource, nil
|
||||||
}
|
}
|
||||||
@ -273,7 +273,7 @@ func GetAnthroveUser(ctx context.Context, driver neo4j.DriverWithContext, anthro
|
|||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_user_id": anthroveUserID,
|
"anthrove_user_id": anthroveUserID,
|
||||||
}).Trace("graph: got anthrove user")
|
}).Trace("database: got anthrove user")
|
||||||
|
|
||||||
return &anthroveUser, nil
|
return &anthroveUser, nil
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ func GetAllAnthroveUserIDs(ctx context.Context, driver neo4j.DriverWithContext)
|
|||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_user_id_count": len(anthroveUsers),
|
"anthrove_user_id_count": len(anthroveUsers),
|
||||||
}).Trace("graph: got al anthrove user IDs")
|
}).Trace("database: got al anthrove user IDs")
|
||||||
|
|
||||||
return anthroveUsers, nil
|
return anthroveUsers, nil
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ func GetUserFavoriteNodeWithPagination(ctx context.Context, driver neo4j.DriverW
|
|||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"anthrove_user_fav_count": len(favoritePosts),
|
"anthrove_user_fav_count": len(favoritePosts),
|
||||||
}).Trace("graph: got al anthrove user favorites")
|
}).Trace("database: got al anthrove user favorites")
|
||||||
|
|
||||||
return &models.FavoriteList{Posts: favoritePosts}, nil
|
return &models.FavoriteList{Posts: favoritePosts}, nil
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ func GetUserTagNodeWitRelationToFavedPosts(ctx context.Context, driver neo4j.Dri
|
|||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"tag_amount": len(userTags),
|
"tag_amount": len(userTags),
|
||||||
}).Trace("graph: created tag node")
|
}).Trace("database: created tag node")
|
||||||
|
|
||||||
return userTags, nil
|
return userTags, nil
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Package graph provides a client for using the OtterSpace API.
|
// Package database provides a client for using the OtterSpace API.
|
||||||
//
|
//
|
||||||
// This package provides a client to interact with the OtterSpace API. It includes
|
// This package provides a client to interact with the OtterSpace API. It includes
|
||||||
// methods for all API endpoints, and convenience methods for common tasks.
|
// methods for all API endpoints, and convenience methods for common tasks.
|
||||||
@ -11,11 +11,11 @@
|
|||||||
// "context"
|
// "context"
|
||||||
// "fmt"
|
// "fmt"
|
||||||
// "git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
// "git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||||
// "git.dragse.it/anthrove/otter-space-sdk/pkg/graph"
|
// "git.dragse.it/anthrove/otter-space-sdk/pkg/database"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func main() {
|
// func main() {
|
||||||
// client := graph.NewGraphConnection()
|
// client := database.NewGraphConnection()
|
||||||
// err := client.Connect(context.Background(), "your-endpoint", "your-username", "your-password")
|
// err := client.Connect(context.Background(), "your-endpoint", "your-username", "your-password")
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// fmt.Println(err)
|
// fmt.Println(err)
|
||||||
@ -23,7 +23,7 @@
|
|||||||
// }
|
// }
|
||||||
// // further usage of the client...
|
// // further usage of the client...
|
||||||
// }
|
// }
|
||||||
package graph
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -39,63 +39,63 @@ type OtterSpace interface {
|
|||||||
// It returns an error if the connection cannot be established.
|
// It returns an error if the connection cannot be established.
|
||||||
Connect(ctx context.Context, endpoint string, username string, password string) error
|
Connect(ctx context.Context, endpoint string, username string, password string) error
|
||||||
|
|
||||||
// AddUserWithRelationToSource adds a new user to the OtterSpace graph and associates them with a source.
|
// AddUserWithRelationToSource adds a new user to the OtterSpace database and associates them with a source.
|
||||||
// It returns the newly created user and an error if the operation fails.
|
// It returns the newly created user and an error if the operation fails.
|
||||||
AddUserWithRelationToSource(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDomain string, userID string, username string) error
|
AddUserWithRelationToSource(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDomain string, userID string, username string) error
|
||||||
|
|
||||||
// AddSource adds a new source to the OtterSpace graph.
|
// AddSource adds a new source to the OtterSpace database.
|
||||||
// It returns an error if the operation fails.
|
// It returns an error if the operation fails.
|
||||||
AddSource(ctx context.Context, anthroveSource *models.AnthroveSource) error
|
AddSource(ctx context.Context, anthroveSource *models.AnthroveSource) error
|
||||||
|
|
||||||
// AddPost adds a new post to the OtterSpace graph.
|
// AddPost adds a new post to the OtterSpace database.
|
||||||
// It returns an error if the operation fails.
|
// It returns an error if the operation fails.
|
||||||
AddPost(ctx context.Context, anthrovePost *models.AnthrovePost) error
|
AddPost(ctx context.Context, anthrovePost *models.AnthrovePost) error
|
||||||
|
|
||||||
// AddTagWithRelationToPost adds a new tag to the OtterSpace graph and associates it with a post.
|
// AddTagWithRelationToPost adds a new tag to the OtterSpace database and associates it with a post.
|
||||||
// It returns an error if the operation fails.
|
// It returns an error if the operation fails.
|
||||||
AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.AnthroveTag) error
|
AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.AnthroveTag) error
|
||||||
|
|
||||||
// LinkPostWithSource establishes a link between a post and a source in the OtterSpace graph.
|
// LinkPostWithSource establishes a link between a post and a source in the OtterSpace database.
|
||||||
// It returns an error if the operation fails.
|
// It returns an error if the operation fails.
|
||||||
LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error
|
LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error
|
||||||
|
|
||||||
// LinkUserWithPost establishes a link between a user and a post in the OtterSpace graph.
|
// LinkUserWithPost establishes a link between a user and a post in the OtterSpace database.
|
||||||
// It returns an error if the operation fails.
|
// It returns an error if the operation fails.
|
||||||
LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error
|
LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error
|
||||||
|
|
||||||
// CheckUserPostLink checks if a link between a user and a post exists in the OtterSpace graph.
|
// CheckUserPostLink checks if a link between a user and a post exists in the OtterSpace database.
|
||||||
// It returns true if the link exists, false otherwise, and an error if the operation fails.
|
// It returns true if the link exists, false otherwise, and an error if the operation fails.
|
||||||
CheckUserPostLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourcePostID string, sourceUrl string) (bool, error)
|
CheckUserPostLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourcePostID string, sourceUrl string) (bool, error)
|
||||||
|
|
||||||
// CheckPostNodeExistsByAnthroveID checks if a post node exists in the OtterSpace graph by its Anthrove ID.
|
// CheckPostNodeExistsByAnthroveID checks if a post node exists in the OtterSpace database by its Anthrove ID.
|
||||||
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
|
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
|
||||||
CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error)
|
CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error)
|
||||||
|
|
||||||
// CheckPostNodeExistsBySourceURL checks if a post node exists in the OtterSpace graph by its source URL.
|
// CheckPostNodeExistsBySourceURL checks if a post node exists in the OtterSpace database by its source URL.
|
||||||
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
|
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
|
||||||
CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error)
|
CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error)
|
||||||
|
|
||||||
// CheckPostNodeExistsBySourceID checks if a post node exists in the OtterSpace graph by its source ID.
|
// CheckPostNodeExistsBySourceID checks if a post node exists in the OtterSpace database by its source ID.
|
||||||
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
|
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
|
||||||
CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error)
|
CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error)
|
||||||
|
|
||||||
// GetUserFavoriteCount retrieves the count of a user's favorite posts from the OtterSpace graph.
|
// GetUserFavoriteCount retrieves the count of a user's favorite posts from the OtterSpace database.
|
||||||
// It returns the count and an error if the operation fails.
|
// It returns the count and an error if the operation fails.
|
||||||
GetUserFavoriteCount(ctx context.Context, anthroveUserID models.AnthroveUserID) (int64, error)
|
GetUserFavoriteCount(ctx context.Context, anthroveUserID models.AnthroveUserID) (int64, error)
|
||||||
|
|
||||||
// GetUserSourceLinks retrieves the links between a user and sources in the OtterSpace graph.
|
// GetUserSourceLinks retrieves the links between a user and sources in the OtterSpace database.
|
||||||
// It returns a map of source domains to user-source relationships, and an error if the operation fails.
|
// It returns a map of source domains to user-source relationships, and an error if the operation fails.
|
||||||
GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error)
|
GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error)
|
||||||
|
|
||||||
// GetSpecifiedUserSourceLink GetUserSourceLinks retrieves the links between a user and a specific source in the OtterSpace graph.
|
// GetSpecifiedUserSourceLink GetUserSourceLinks retrieves the links between a user and a specific source in the OtterSpace database.
|
||||||
// It returns a map of source domains to user-source relationships, and an error if the operation fails.
|
// It returns a map of source domains to user-source relationships, and an error if the operation fails.
|
||||||
GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]models.AnthroveUserRelationship, error)
|
GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]models.AnthroveUserRelationship, error)
|
||||||
|
|
||||||
// GetAnthroveUser retrieves a user from the OtterSpace graph by their ID.
|
// GetAnthroveUser retrieves a user from the OtterSpace database by their ID.
|
||||||
// It returns the user and an error if the operation fails.
|
// It returns the user and an error if the operation fails.
|
||||||
GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*models.AnthroveUser, error)
|
GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*models.AnthroveUser, error)
|
||||||
|
|
||||||
// GetAllAnthroveUserIDs retrieves all user IDs from the OtterSpace graph.
|
// GetAllAnthroveUserIDs retrieves all user IDs from the OtterSpace database.
|
||||||
// It returns a slice of user IDs and an error if the operation fails.
|
// It returns a slice of user IDs and an error if the operation fails.
|
||||||
GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error)
|
GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error)
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package graph
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
Reference in New Issue
Block a user