database

package
v0.0.0-...-c6eb422 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllPossibleParams

type AllPossibleParams struct {
	Width  int    `json:"width,omitempty"`
	Axis   string `json:"axis,omitempty"`
	Angle  int    `json:"angle,omitempty"`
	X      int    `json:"x,omitempty"`
	Y      int    `json:"y,omitempty"`
	Height int    `json:"height,omitempty"`
}

type CropParams

type CropParams struct {
	X      int `json:"x"`
	Y      int `json:"y"`
	Width  int `json:"width"`
	Height int `json:"height"`
}

CropParams holds the parameters for the Crop operation

type DB

type DB struct {
	*sqlx.DB
}

func New

func New(dsn string, automigrate bool) (*DB, error)

func (*DB) DeleteTask

func (db *DB) DeleteTask(id, userId int) error

func (*DB) GetTask

func (db *DB) GetTask(id, userId int) (*Task, error)

func (*DB) GetUser

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

func (*DB) GetUserByEmail

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

func (*DB) InsertTask

func (db *DB) InsertTask(task *Task, AfterCreate func(createdTask *Task) error) error

func (*DB) InsertUser

func (db *DB) InsertUser(email, hashedPassword string) (int, error)

func (*DB) ListTasks

func (db *DB) ListTasks(userId int, filters Filters) ([]*Task, error)

func (*DB) UpdateTask

func (db *DB) UpdateTask(task *Task) error

func (*DB) UpdateUserHashedPassword

func (db *DB) UpdateUserHashedPassword(id int, hashedPassword string) error

type Filters

type Filters struct {
	Page     int
	PageSize int
}

type FlipParams

type FlipParams struct {
	Axis string `json:"axis"`
}

type OperationType

type OperationType string
const (
	Resize OperationType = "resize"
	Crop   OperationType = "crop"
	Rotate OperationType = "rotate"
	Flip   OperationType = "flip"
)

type Payload

type Payload struct {
	URL       string          `json:"url"`
	Operation OperationType   `json:"operation"`
	Params    TransformParams `json:"params,omitempty"`
}

func (*Payload) Scan

func (p *Payload) Scan(value interface{}) error

func (*Payload) UpdateParams

func (p *Payload) UpdateParams(op OperationType, params AllPossibleParams) error

func (Payload) Value

func (p Payload) Value() (driver.Value, error)

type ResizeParams

type ResizeParams struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

ResizeParams holds the parameters for the Resize operation

type RotateParams

type RotateParams struct {
	Angle int `json:"angle"`
}

RotateParams holds the parameters for the Rotate operation

type Task

type Task struct {
	ID         int       `db:"id" json:"id"`
	Type       string    `db:"type" json:"type"`
	Payload    Payload   `db:"payload" json:"payload"`
	Priority   int       `db:"priority" json:"priority"`
	Status     string    `db:"status" json:"status"`
	CreatedAt  time.Time `db:"created_at" json:"created_at"`
	UpdatedAt  time.Time `db:"updated_at" json:"updated_at"`
	Timeout    int       `db:"timeout" json:"timeout"`
	RetryCount int       `db:"retry_count" json:"retry_count"`
	MaxRetries int       `db:"max_retries" json:"max_retries"`
	Result     string    `db:"result" json:"result,omitempty"`
	UserId     int       `db:"user_id" json:"-"`
}

type TransformParams

type TransformParams struct {
	ResizeParams ResizeParams
	CropParams   CropParams
	RotateParams RotateParams
	FlipParams   FlipParams
}

type User

type User struct {
	ID           int       `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"`
	Version      int       `db:"version" json:"-"`
	PasswordHash string    `db:"password_hash" json:"password_hash"`
}

Jump to

Keyboard shortcuts

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