models

package
v0.0.0-...-9d3d7fb Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_ICON_UPLOAD_SIZE = 5 << 20             // 5MB
	ACCESS_TOKEN_LIVE    = 15 * time.Minute    // 15 minutes
	REFRESH_TOKEN_LIVE   = 30 * 24 * time.Hour // 30 days
)
View Source
const (
	// Select
	SqlSelectUserById           = `SELECT * FROM "users" WHERE id = $1 LIMIT 1`
	SqlSelectUserByEmail        = `SELECT * FROM "users" WHERE email = $1 LIMIT 1`
	SqlSelectAllUsersById       = `SELECT * FROM "users" WHERE id = $1 ORDER BY "users"."id"`
	SqlSelectAllUsersByEmail    = `SELECT * FROM "users" WHERE email = $1 ORDER BY "users"."id"`
	SqlSelectAllUsersByUsername = `SELECT * FROM "users" WHERE username = $1 ORDER BY "users"."id"`

	SqlSelectListById                   = `SELECT * FROM "lists" WHERE id = $1 LIMIT 1`
	SqlSelectListByIdAndUserId          = `SELECT * FROM "lists" WHERE id = $1 AND user_id = $2 LIMIT 1`
	SqlSelectAllListsByUserId           = `SELECT * FROM "lists" WHERE user_id = $1 ORDER BY index`
	SqlSelectAllListsForEditIndex       = `SELECT * FROM "lists" WHERE user_id = $1 AND index > $2`
	SqlSelectMaxListIndex               = `SELECT max(index) FROM "lists" WHERE user_id = $1 LIMIT 1`
	SqlSelectAllListsToIncreaseTheIndex = `SELECT * FROM "lists" WHERE user_id = $1 AND index <= $2 AND index > $3`
	SqlSelectAllListsForIndexReduction  = `SELECT * FROM "lists" WHERE user_id = $1 AND index >= $2 AND index < $3`

	SqlSelectTaskById                   = `SELECT * FROM "tasks" WHERE id = $1 LIMIT 1`
	SqlSelectAllTasksByListId           = `SELECT * FROM "tasks" WHERE list_id = $1 ORDER BY index`
	SqlSelectAllTasksForEditIndex       = `SELECT * FROM "tasks" WHERE list_id = $1 AND index > $2`
	SqlSelectMaxTaskIndex               = `SELECT max(index) FROM "tasks" WHERE list_id = $1 LIMIT 1`
	SqlSelectAllTasksToIncreaseTheIndex = `SELECT * FROM "tasks" WHERE list_id = $1 AND index <= $2 AND index > $3`
	SqlSelectAllTasksForIndexReduction  = `SELECT * FROM "tasks" WHERE list_id = $1 AND index >= $2 AND index < $3`

	SqlSelectAllSubtasksByTaskId           = `SELECT * FROM "tasks" WHERE task_id = $1 ORDER BY index`
	SqlSelectTaskIdBySubtaskId             = `SELECT task_id FROM "tasks" WHERE id = $1 LIMIT 1`
	SqlSelectMaxSubtaskIndex               = `SELECT max(index) FROM "tasks" WHERE task_id = $1 LIMIT 1`
	SqlSelectAllSubtasksForEditIndex       = `SELECT * FROM "tasks" WHERE task_id = $1 AND index > $2`
	SqlSelectAllSubtasksToIncreaseTheIndex = `SELECT * FROM "tasks" WHERE task_id = $1 AND index <= $2 AND index > $3`
	SqlSelectAllSubtasksForIndexReduction  = `SELECT * FROM "tasks" WHERE task_id = $1 AND index >= $2 AND index < $3`

	// Select with join
	SqlSelectListIdWhereTask = `SELECT lists.id FROM "lists" INNER JOIN tasks ON lists.id=tasks.list_id WHERE user_id = $1 AND tasks.id = $2 LIMIT 1`

	// Insert
	SqlInsertUserData = `INSERT INTO "users" ("email","password","name","username","icon","id") VALUES ($1,$2,$3,$4,$5,$6) RETURNING "id"`

	SqlInsertListData = `INSERT INTO "lists" ("user_id","name","comment","index","id") VALUES ($1,$2,$3,$4,$5) RETURNING "id"`

	SqlInsertTaskData = `` /* 167-byte string literal not displayed */

	// Delete
	SqlDeleteUser = `DELETE FROM "users" WHERE "users"."id" = $1`

	SqlDeleteList = `DELETE FROM "lists" WHERE "lists"."id" = $1`

	SqlDeleteTask = `DELETE FROM "tasks" WHERE "tasks"."id" = $1`

	// Edit
	SqlEditUserName     = `UPDATE "users" SET "name"=$1 WHERE "users"."id" = $2`
	SqlEditUserIcon     = `UPDATE "users" SET "icon"=$1 WHERE id = $2`
	SqlEditUserEmail    = `UPDATE "users" SET "email"=$1 WHERE "users"."id" = $2`
	SqlEditUserUsername = `UPDATE "users" SET "username"=$1 WHERE "users"."id" = $2`
	SqlEditUserPassword = `UPDATE "users" SET "password"=$1 WHERE email = $2`

	SqlEditList      = `UPDATE "lists" SET "name"=$1,"comment"=$2 WHERE "id" = $3`
	SqlEditListIndex = `UPDATE "lists" SET "index"=$1 WHERE id = $2`

	SqlEditTask      = `UPDATE "tasks" SET "name"=$1,"comment"=$2,"categories"=$3,"end_time"=$4,"done"=$5,"special"=$6 WHERE "id" = $7`
	SqlEditTaskIndex = `UPDATE "tasks" SET "index"=$1 WHERE id = $2`
)
View Source
const BucketName = "user-icons"

Variables

View Source
var (
	IMAGE_TYPES = map[string]interface{}{
		"image/jpeg": ".jpeg",
		"image/png":  ".png",
	}
)

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	Error string `json:"error"`
}

type ApiListData

type ApiListData struct {
	Name    string `json:"name" example:"List of products"`
	Comment string `json:"comment" example:"Products needed for the party"`
}

type ApiMessage

type ApiMessage struct {
	Message string `json:"message"`
}

type ApiShowLists

type ApiShowLists struct {
	Lists []ListsData `json:"lists"`
}

type ApiShowSubtasks

type ApiShowSubtasks struct {
	Subtasks []SubtasksData `json:"subtasks"`
}

type ApiShowTasks

type ApiShowTasks struct {
	Tasks []TasksData `json:"tasks"`
}

type ApiSubtaskData

type ApiSubtaskData struct {
	TaskId  int    `json:"task_id" example:"1023456789"`
	Name    string `json:"name" example:"Coca-Cola"`
	Comment string `json:"comment" example:"Sugar-free"`
}

type ApiTaskData

type ApiTaskData struct {
	ListId  int    `json:"list_id" example:"1023456789"`
	Name    string `json:"name" example:"Buy drinks"`
	Comment string `json:"comment" example:"Go to the supermarket on the way home"`
}

type FileUnit

type FileUnit struct {
	Icon        io.Reader
	Size        int64
	ContentType string
	ID          int
}

type ListEditData

type ListEditData struct {
	Id      int    `json:"id" example:"1023456789"`
	Name    string `json:"name" example:"New list of products"`
	Comment string `json:"comment" example:"Products needed for the party"`
	Index   int    `json:"index" example:"1"`
}

type Lists

type Lists struct {
	Id      int
	UserId  int
	Name    string
	Comment string
	Index   int
}

type ListsData

type ListsData struct {
	Id      int    `json:"id" example:"1023456789"`
	Name    string `json:"name" example:"List of products"`
	Comment string `json:"comment" example:"Products needed for the party"`
	Index   int    `json:"index" example:"0"`
}

type Mail

type Mail struct {
	From    string
	Temp    string
	Name    string
	Email   string
	Emails  []string
	Subject string
}

type ShowUserData

type ShowUserData struct {
	Id       int    `json:"id" example:"1023456789"`
	Name     string `json:"name" example:"NKTKLN"`
	Username string `json:"username" example:"nktkln"`
}

type SubtaskEditData

type SubtaskEditData struct {
	Id         int            `json:"id" example:"1023456789"`
	Name       string         `json:"name" example:"Pepsi"`
	Comment    string         `json:"comment" example:"Sugar-free"`
	Index      int            `json:"index" example:"1"`
	Categories pq.StringArray `gorm:"type:text[]" json:"categories" example:"Party,Shoping,Today"`
	EndTime    string         `json:"end_time" example:"2077-12-10 13:13"`
	Done       bool           `json:"done" example:"true"`
	Special    bool           `json:"special" example:"true"`
}

type SubtasksData

type SubtasksData struct {
	Id         int            `json:"id" example:"1023456789"`
	Name       string         `json:"name" example:"Coca-Cola"`
	Comment    string         `json:"comment" example:"Sugar-free"`
	Index      int            `json:"index" example:"0"`
	Categories pq.StringArray `gorm:"type:text[]" json:"categories" example:"Party,Shoping"`
	EndTime    string         `json:"end_time" example:"2077-12-10 13:13"`
	Done       bool           `json:"done"`
	Special    bool           `json:"special"`
}

type TaskEditData

type TaskEditData struct {
	Id         int            `json:"id" example:"1023456789"`
	Name       string         `json:"name" example:"Buy new drinks"`
	Comment    string         `json:"comment" example:"Go to the supermarket on the way home"`
	Index      int            `json:"index" example:"1"`
	Categories pq.StringArray `gorm:"type:text[]" json:"categories" example:"Party,Shoping,Today"`
	EndTime    string         `json:"end_time" example:"2077-12-10 13:13"`
	Done       bool           `json:"done" example:"true"`
	Special    bool           `json:"special" example:"true"`
}

type Tasks

type Tasks struct {
	Id         int
	ListId     int
	TaskId     int
	Name       string
	Comment    string
	Index      int
	Categories pq.StringArray `gorm:"type:text[]"`
	EndTime    time.Time
	Done       bool
	Special    bool
}

type TasksData

type TasksData struct {
	Id         int            `json:"id" example:"1023456789"`
	Name       string         `json:"name" example:"Buy drinks"`
	Comment    string         `json:"comment" example:"Go to the supermarket on the way home"`
	Index      int            `json:"index" example:"0"`
	Categories pq.StringArray `gorm:"type:text[]" json:"categories" example:"Party,Shoping"`
	EndTime    string         `json:"end_time" example:"2077-12-10 13:13"`
	Done       bool           `json:"done"`
	Special    bool           `json:"special"`
}

type UserData

type UserData struct {
	Email    string `json:"email" example:"nktkln@example.com"`
	Password string `json:"password" example:"StRon9Pa$$w0rd"`
	Name     string `json:"name" example:"NKTKLN"`
	Username string `json:"username" example:"nktkln"`
}

type UserEmail

type UserEmail struct {
	Email string `json:"email" example:"nktkln@example.com"`
}

type UserLoginData

type UserLoginData struct {
	Email    string `json:"email" example:"nktkln@example.com"`
	Password string `json:"password" example:"StRon9Pa$$w0rd"`
}

type UserName

type UserName struct {
	Name string `json:"name" example:"NKTKLN"`
}

type UserPassword

type UserPassword struct {
	Password string `json:"password" example:"StRon9Pa$$w0rd"`
}

type UserTokens

type UserTokens struct {
	AccessToken  string `` /* 159-byte string literal not displayed */
	RefreshToken string `` /* 160-byte string literal not displayed */
}

type UserUsername

type UserUsername struct {
	Username string `json:"username" example:"nktkln"`
}

type Users

type Users struct {
	Id       int
	Email    string
	Password string
	Name     string
	Username string
	Icon     string
}

Jump to

Keyboard shortcuts

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