This commit is contained in:
2025-04-05 18:45:17 +11:00
parent 35c27b28a3
commit 7f5a09098a
72 changed files with 56 additions and 3351 deletions

View File

@@ -2,7 +2,6 @@ package igdb
import (
"fmt"
"strings"
pb "github.com/bestnite/go-igdb/proto"
@@ -26,64 +25,3 @@ func (g *Client) GetCollectionRelationTypes(query string) ([]*pb.CollectionRelat
return data.Collectionrelationtypes, nil
}
func (g *Client) GetCollectionRelationTypeByID(id uint64) (*pb.CollectionRelationType, error) {
query := fmt.Sprintf(`where id=%d; fields *;`, id)
collectionRelationTypes, err := g.GetCollectionRelationTypes(query)
if err != nil {
return nil, err
}
return collectionRelationTypes[0], nil
}
func (g *Client) GetCollectionRelationTypesByIDs(ids []uint64) ([]*pb.CollectionRelationType, error) {
idStrSlice := make([]string, len(ids))
for i, id := range ids {
idStrSlice[i] = fmt.Sprintf("%d", id)
}
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
return g.GetCollectionRelationTypes(idStr)
}
func (g *Client) GetCollectionRelationTypesByAllowedChildTypeID(id uint64) ([]*pb.CollectionRelationType, error) {
query := fmt.Sprintf(`where allowed_child_type = %d; fields *;`, id)
return g.GetCollectionRelationTypes(query)
}
func (g *Client) GetCollectionRelationTypesByAllowedChildTypeIDs(ids []uint64) ([]*pb.CollectionRelationType, error) {
idStrSlice := make([]string, len(ids))
for i, id := range ids {
idStrSlice[i] = fmt.Sprintf("%d", id)
}
idStr := fmt.Sprintf(`where allowed_child_type = (%s); fields *;`, strings.Join(idStrSlice, ","))
return g.GetCollectionRelationTypes(idStr)
}
func (g *Client) GetCollectionRelationTypesByAllowedParentTypeID(id uint64) ([]*pb.CollectionRelationType, error) {
query := fmt.Sprintf(`where allowed_parent_type = %d; fields *;`, id)
return g.GetCollectionRelationTypes(query)
}
func (g *Client) GetCollectionRelationTypesByAllowedParentTypeIDs(ids []uint64) ([]*pb.CollectionRelationType, error) {
idStrSlice := make([]string, len(ids))
for i, id := range ids {
idStrSlice[i] = fmt.Sprintf("%d", id)
}
idStr := fmt.Sprintf(`where allowed_parent_type = (%s); fields *;`, strings.Join(idStrSlice, ","))
return g.GetCollectionRelationTypes(idStr)
}
func (g *Client) GetCollectionRelationTypesLength() (int, error) {
query := `fields *; sort id desc; limit 1;`
collectionRelationTypes, err := g.GetCollectionRelationTypes(query)
if err != nil {
return 0, err
}
return int(collectionRelationTypes[0].Id), nil
}