Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Package = do.Package( do.Lazy(NewDatabase), do.Lazy(NewUserRepository), )
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents a PostgreSQL connection pool This service demonstrates how to create and manage database connections using dependency injection.
func NewDatabase ¶
NewDatabase creates a new PostgreSQL database connection pool This function demonstrates how to initialize a service with dependencies using samber/do.
func (*Database) HealthCheckWithContext ¶
HealthCheckWithContext the database connection This method demonstrates how to implement health checks for services.
type User ¶
type User struct {
ID int64 `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
User represents a user model This struct demonstrates how to define domain models for data access.
type UserRepository ¶
type UserRepository interface {
CreateUser(ctx context.Context, user *User) (*User, error)
GetUserByID(ctx context.Context, id int64) (*User, error)
GetUserByEmail(ctx context.Context, email string) (*User, error)
UpdateUser(ctx context.Context, user *User) (*User, error)
DeleteUser(ctx context.Context, id int64) error
ListUsers(ctx context.Context, limit, offset int) ([]*User, error)
}
UserRepository defines the interface for user data access operations This interface demonstrates how to define contracts for repository pattern.
func NewUserRepository ¶
func NewUserRepository(injector do.Injector) (UserRepository, error)
NewUserRepository creates a new UserRepository instance This function demonstrates how to initialize a repository with database dependency.