models

package
v0.0.0-...-cad2f22 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBName   string `envconfig:"NAME"`
	User     string `envconfig:"USER"`
	Password string `envconfig:"PASSWORD"`
	Host     string `envconfig:"HOST"`
	Port     int    `envconfig:"PORT"`
	SSLMode  string `envconfig:"SSL_MODE"`
}

func (Config) ConnectionString

func (c Config) ConnectionString() string

func (Config) URL

func (c Config) URL() string

type DB

type DB struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(conf Config) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) CreateUser

func (db *DB) CreateUser(u *User) (*User, error)

func (*DB) DeleteUser

func (db *DB) DeleteUser(id int) error

func (*DB) GetUserByID

func (db *DB) GetUserByID(id int) (*User, error)

func (*DB) GetUsers

func (db *DB) GetUsers() ([]*User, error)

func (*DB) UpdateUser

func (db *DB) UpdateUser(u *User) error

type User

type User struct {
	ID   int    `db:"id" json:"id" formam:"id"`
	Name string `db:"name" json:"name" formam:"name"`
}

Jump to

Keyboard shortcuts

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