Overwrite a Repository Method
To change and fine tune the behaviour of an existing method overwrite it.
user.inmemoery.repository.go
package main
import (
"context"
"github.com/go-arrower/arrower/repository"
)
type UserID int
type User struct {
ID UserID
Login string
}
func main() {
repo := NewUserMemoryRepository()
_, err := repo.Count(context.Background())
if err != nil {
panic(err)
}
}
func NewUserMemoryRepository() *UserMemoryRepository {
return &UserMemoryRepository{
MemoryRepository: repository.NewMemoryRepository[User, UserID](),
}
}
type UserMemoryRepository struct {
*repository.MemoryRepository[User, UserID]
}
// Count overwrites the existing Count method with your own implementation.
func (repo *UserMemoryRepository) Count(_ context.Context) (int, error) {
return -1, nil
}