This commit is contained in:
2025-04-08 12:58:14 +10:00
parent 7076e9d259
commit 95f46cc7e7
8 changed files with 495 additions and 360 deletions

View File

@ -2,7 +2,6 @@ package model
import (
pb "github.com/bestnite/go-igdb/proto"
"go.mongodb.org/mongo-driver/v2/bson"
"google.golang.org/protobuf/types/known/timestamppb"
)
@ -10,7 +9,6 @@ type GameIds []uint64
type GameId uint64
type Game struct {
MId bson.ObjectID `json:"_id,omitempty"`
Id uint64 `json:"id,omitempty"`
AgeRatings []*pb.AgeRating `json:"age_ratings,omitempty"`
AggregatedRating float64 `json:"aggregated_rating,omitempty"`

View File

@ -1,24 +1,20 @@
package model
import (
"go.mongodb.org/mongo-driver/v2/bson"
)
// type Item[T any] struct {
// Item *T `bson:"item"`
// MId bson.ObjectID `bson:"_id"`
// }
type Item[T any] struct {
Item *T `bson:"item"`
MId bson.ObjectID `bson:"_id"`
}
// func NewItem[T any](item *T) *Item[T] {
// return &Item[T]{
// Item: item,
// }
// }
func NewItem[T any](item *T) *Item[T] {
return &Item[T]{
Item: item,
}
}
func NewItems[T any](items []*T) []*Item[T] {
var result []*Item[T]
for _, item := range items {
result = append(result, NewItem(item))
}
return result
}
// func NewItems[T any](items []*T) []*Item[T] {
// var result []*Item[T]
// for _, item := range items {
// result = append(result, NewItem(item))
// }
// return result
// }