psql

package
v0.0.0-...-24e094a Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("psql: resource could not be located")
)

Common errors that you will likely want to account for in your code. Any other errors are wrapped with context vai the github.com/pkg/errors package and returned but are harder to use an if/switch to match.

Functions

This section is empty.

Types

type User

type User struct {
	ID    int
	Name  string
	Email string
}

User is an example user model. This typically wouldn't be defined in this package but is done here for simplicity.

type UserStore

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

UserStore is used to interact with our user store.

func (*UserStore) Create

func (us *UserStore) Create(user *User) error

Create will create a new user in the DB using the provided user and will update the ID of the provided user. If there is an error it will be wrapped and returned.

func (*UserStore) Delete

func (us *UserStore) Delete(id int) error

Delete will delete a user form the DB. If there is an error it will be wrapped and returned.

func (*UserStore) Find

func (us *UserStore) Find(id int) (*User, error)

Find will retrieve a user with the provided ID or return ErrNotFount if the user isn't located. Other errors are wrapped with context but are otherwise wrapped as-is.

Jump to

Keyboard shortcuts

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