psql

package
v0.0.0-...-1a85a4d Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package psql implements a User Repository backed by a PostgreSQL database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	ID    string
	Email string
}

User represents a database user entity.

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

UserRepository stores the database connection on which CRUD actions are executed.

func NewUserRepository

func NewUserRepository(db *sql.DB) *UserRepository

NewUserRepository creates an initialized UserRepository.

func (UserRepository) AddUser

func (u UserRepository) AddUser(
	ctx context.Context,
	user User,
) error

AddUser inserts a User in the database.

func (UserRepository) GetUser

func (u UserRepository) GetUser(
	ctx context.Context,
	id string,
) (User, error)

GetUser retrieves a user from the database.

Jump to

Keyboard shortcuts

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