Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseModelInterface ¶
type BaseModelInterface interface { GetID() string SetID(id primitive.ObjectID) GetCreatedAt() *timestamppb.Timestamp SetCreatedAt(t *timestamppb.Timestamp) GetUpdatedAt() *timestamppb.Timestamp SetUpdatedAt(t *timestamppb.Timestamp) }
BaseModelInterface ensures that the type has an embedded BaseModel or equivalent fields.
type IRepository ¶
type IRepository[T BaseModelInterface] interface { Create(c context.Context, item T) error GetByID(c context.Context, id string) (item T, err error) List(c context.Context, cond Pagination) (items []T, total int, err error) Update(c context.Context, item T) error Delete(c context.Context, id string) error }
IRepository is a generic interface for repositories.
func NewMongoRepository ¶
func NewMongoRepository[T BaseModelInterface](coll *mongo.Collection) IRepository[T]
NewMongoRepository is to create a new mongo repository.
type Pagination ¶
Pagination is a struct for pagination.
Click to show internal directories.
Click to hide internal directories.