db

package
v0.0.0-...-6a21cee Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schema string

Functions

func CreateTables

func CreateTables(ctx context.Context, db *sql.DB) error

Types

type CreateTodoParams

type CreateTodoParams struct {
	UserID      int64          `json:"user_id"`
	Title       string         `json:"title"`
	Description sql.NullString `json:"description"`
	Done        sql.NullBool   `json:"done"`
}

type CreateUserParams

type CreateUserParams struct {
	Login     string `json:"login"`
	Email     string `json:"email"`
	AvatarURL string `json:"avatar_url"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateTodo

func (q *Queries) CreateTodo(ctx context.Context, arg CreateTodoParams) (Todo, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) DeleteTodo

func (q *Queries) DeleteTodo(ctx context.Context, id int64) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id int64) error

func (*Queries) GetTodoById

func (q *Queries) GetTodoById(ctx context.Context, id int64) (Todo, error)

func (*Queries) GetTodosByUserId

func (q *Queries) GetTodosByUserId(ctx context.Context, userID int64) ([]Todo, error)

func (*Queries) GetUserById

func (q *Queries) GetUserById(ctx context.Context, id int64) (User, error)

func (*Queries) GetUserByLogin

func (q *Queries) GetUserByLogin(ctx context.Context, login string) (User, error)

func (*Queries) GetUsers

func (q *Queries) GetUsers(ctx context.Context) ([]User, error)

func (*Queries) UpdateTodo

func (q *Queries) UpdateTodo(ctx context.Context, arg UpdateTodoParams) error

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Session

type Session struct {
	Token  string  `json:"token"`
	Data   []byte  `json:"data"`
	Expiry float64 `json:"expiry"`
}

type Todo

type Todo struct {
	ID          int64          `json:"id"`
	UserID      int64          `json:"user_id"`
	CreatedAt   sql.NullTime   `json:"created_at"`
	UpdatedAt   sql.NullTime   `json:"updated_at"`
	CompletedAt sql.NullTime   `json:"completed_at"`
	Title       string         `json:"title"`
	Description sql.NullString `json:"description"`
	Done        sql.NullBool   `json:"done"`
}

type UpdateTodoParams

type UpdateTodoParams struct {
	Title       string         `json:"title"`
	Description sql.NullString `json:"description"`
	Done        sql.NullBool   `json:"done"`
	ID          int64          `json:"id"`
}

type UpdateUserParams

type UpdateUserParams struct {
	Login     string `json:"login"`
	Email     string `json:"email"`
	AvatarURL string `json:"avatar_url"`
	ID        int64  `json:"id"`
}

type User

type User struct {
	ID        int64  `json:"id"`
	Login     string `json:"login"`
	Email     string `json:"email"`
	AvatarURL string `json:"avatar_url"`
}

func CreateOrGetUser

func CreateOrGetUser(ctx context.Context, database *Queries, user CreateUserParams) (User, error)

Create a new user or get an existing user

Jump to

Keyboard shortcuts

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