repositories

package
v0.0.0-...-70955ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

func NewDatabase(injector do.Injector) (*Database, error)

NewDatabase creates a new PostgreSQL database connection pool This function demonstrates how to initialize a service with dependencies using samber/do.

func (*Database) HealthCheckWithContext

func (db *Database) HealthCheckWithContext(ctx context.Context) error

HealthCheckWithContext the database connection This method demonstrates how to implement health checks for services.

func (*Database) Pool

func (db *Database) Pool() *pgxpool.Pool

Pool returns the underlying pgxpool.Pool This method demonstrates how to expose dependencies to other services.

func (*Database) Shutdown

func (db *Database) Shutdown() error

Shutdown the database connection.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL