models

package
v0.0.0-...-ba246f5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDBError

func NewDBError(code int16, error string) error

func NewSQLError

func NewSQLError(code int16, error string) error

Types

type DB

type DB struct {
	*sqlx.DB
}

Set up database connection layer

func NewDB

func NewDB(connectionString string) (*DB, error)

TODO: Maybe return a DBError here instead

func (*DB) CreateUser

func (db *DB) CreateUser(user *User) error

User CRUD Functions

func (*DB) DeleteUser

func (db *DB) DeleteUser(userID uuid.UUID) error

func (*DB) GetUserByEmail

func (db *DB) GetUserByEmail(email string) (*User, error)

idfc anymore, i just want this to work now if user doesnt exist, ask user to register

func (*DB) UpdateUser

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

type DBError

type DBError struct {
	Code int16
	Err  string
}

Custom Error Handling DBError for issues working with the database SQLError for errors running queries (might merge the two depending on what happens)

func (*DBError) Error

func (e *DBError) Error() string

type SQLError

type SQLError struct {
	Code int16
	Err  string
}

func (*SQLError) Error

func (e *SQLError) Error() string

type Task

type Task struct {
	ID          uuid.UUID `db:"id"`
	UserID      uuid.UUID `db:"user_id"`
	Priority    int       `db:"priority" json:"priority"`
	Title       string    `db:"title" json:"title"`
	Description string    `db:"description" json:"description"`
}

type User

type User struct {
	ID    uuid.UUID `db:"id"`
	Name  string    `db:"name" json:"name"`
	Email string    `db:"email" json:"email"`
}

Jump to

Keyboard shortcuts

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