sqlite

package
v0.0.0-...-3dd2d23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplySchema

func ApplySchema(db *sql.DB, schema string) error

ApplySchema applies the schema to the given database.

It takes a *sql.DB as a parameter, which represents the database connection. The function reads the schema from the "schema.sql" file using the Schema embed.FS. It then begins a transaction on the database, executes the schema SQL statements, and commits the transaction. If any error occurs during the process, it is returned.

Returns an error if there was a problem reading the schema file or executing the SQL statements.

func NewDB

func NewDB(dsn string) (*sql.DB, error)

NewDB creates a new database connection with the schema applied.

Types

type CreateProjectParams

type CreateProjectParams struct {
	Name        string         `db:"name" json:"name"`
	Description sql.NullString `db:"description" json:"description"`
	UserID      int64          `db:"user_id" json:"user_id"`
}

type CreateUserParams

type CreateUserParams struct {
	Email     string `db:"email" json:"email"`
	FirstName string `db:"first_name" json:"first_name"`
	LastName  string `db:"last_name" json:"last_name"`
	Password  string `db:"password" json:"password"`
	Role      string `db:"role" json:"role"`
}

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 Epic

type Epic struct {
	ID          int64          `db:"id" json:"id"`
	CreatedAt   time.Time      `db:"created_at" json:"created_at"`
	UpdatedAt   time.Time      `db:"updated_at" json:"updated_at"`
	Name        string         `db:"name" json:"name"`
	Description sql.NullString `db:"description" json:"description"`
	UserID      int64          `db:"user_id" json:"user_id"`
}

type GetProjectsRow

type GetProjectsRow struct {
	Project Project `db:"project" json:"project"`
	User    User    `db:"user" json:"user"`
}

type Project

type Project struct {
	ID          int64          `db:"id" json:"id"`
	CreatedAt   time.Time      `db:"created_at" json:"created_at"`
	UpdatedAt   time.Time      `db:"updated_at" json:"updated_at"`
	Name        string         `db:"name" json:"name"`
	Description sql.NullString `db:"description" json:"description"`
	UserID      int64          `db:"user_id" json:"user_id"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateProject

func (q *Queries) CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error)

func (*Queries) CreateUser

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

func (*Queries) GetProject

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

func (*Queries) GetProjects

func (q *Queries) GetProjects(ctx context.Context) ([]GetProjectsRow, error)

func (*Queries) GetUser

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

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*Queries) GetUsers

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

func (*Queries) WithTx

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

type User

type User struct {
	ID        int64     `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
	Email     string    `db:"email" json:"email"`
	FirstName string    `db:"first_name" json:"first_name"`
	LastName  string    `db:"last_name" json:"last_name"`
	Password  string    `db:"password" json:"password"`
	Role      string    `db:"role" json:"role"`
}

Jump to

Keyboard shortcuts

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