query

package
v0.0.0-...-381a539 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangePasswordParams

type ChangePasswordParams struct {
	Username string
	Passhash []byte
}

type CreatePostParams

type CreatePostParams struct {
	ID          int64
	Username    string
	CoverHash   sql.NullString
	Images      []string
	Description sql.NullString
	Tags        []string
	Location    sql.NullString
}

type CreateSessionParams

type CreateSessionParams struct {
	Token    string
	Username string
	Metadata json.RawMessage
}

type CreateUserParams

type CreateUserParams struct {
	Username string
	Passhash []byte
}

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 DeletePostParams

type DeletePostParams struct {
	ID       int64
	Username string
}

type GetPostParams

type GetPostParams struct {
	ID       int64
	Username string
}

type GetPostRow

type GetPostRow struct {
	ID          int64
	Username    string
	CoverHash   sql.NullString
	Images      []string
	Description sql.NullString
	Tags        []string
	Location    sql.NullString
	Likes       int64
	Liked       int64
}

type LikePostParams

type LikePostParams struct {
	PostID   int64
	Username string
}

type LikedPost

type LikedPost struct {
	Username string
	PostID   int64
	LikedAt  time.Time
}

type LikedPostsRow

type LikedPostsRow struct {
	ID          int64
	Username    string
	CoverHash   sql.NullString
	Images      []string
	Description sql.NullString
	Tags        []string
	Location    sql.NullString
	Likes       int64
}

type NextPostsParams

type NextPostsParams struct {
	ID       int64
	Username string
}

type NextPostsRow

type NextPostsRow struct {
	ID          int64
	Username    string
	CoverHash   sql.NullString
	Images      []string
	Description sql.NullString
	Tags        []string
	Location    sql.NullString
	Likes       int64
	Liked       int64
}

type Post

type Post struct {
	ID          int64
	Username    string
	CoverHash   sql.NullString
	Images      []string
	Description sql.NullString
	Tags        []string
	Location    sql.NullString
}

type PrivateUser

type PrivateUser struct {
	Username        string
	DisplayName     sql.NullString
	Avatar          sql.NullString
	Bio             sql.NullString
	Birthday        sql.NullTime
	FoodPreferences json.RawMessage
}

type PublicUser

type PublicUser struct {
	Username    string
	DisplayName sql.NullString
	Avatar      sql.NullString
	Bio         sql.NullString
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) ChangePassword

func (q *Queries) ChangePassword(ctx context.Context, arg ChangePasswordParams) error

func (*Queries) CreatePost

func (q *Queries) CreatePost(ctx context.Context, arg CreatePostParams) error

CreatePost creates a new post.

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)

func (*Queries) CreateUser

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

func (*Queries) DeletePost

func (q *Queries) DeletePost(ctx context.Context, arg DeletePostParams) (int64, error)

DeletePost deletes a post.

func (*Queries) DeleteSession

func (q *Queries) DeleteSession(ctx context.Context, token string) error

TODO: consider returning an indication

func (*Queries) GetPost

func (q *Queries) GetPost(ctx context.Context, arg GetPostParams) (GetPostRow, error)

GetPost gets a single post.

func (*Queries) LikePost

func (q *Queries) LikePost(ctx context.Context, arg LikePostParams) error

LikePost likes a post.

func (*Queries) LikedPosts

func (q *Queries) LikedPosts(ctx context.Context, username string) ([]LikedPostsRow, error)

LikedPosts returns a user's liked posts.

func (*Queries) NextPosts

func (q *Queries) NextPosts(ctx context.Context, arg NextPostsParams) ([]NextPostsRow, error)

NextPosts paginates the list of posts.

func (*Queries) PostLikeCount

func (q *Queries) PostLikeCount(ctx context.Context, postID int64) (int64, error)

PostLikeCount returns the like count of the post with the given ID.

func (*Queries) Self

func (q *Queries) Self(ctx context.Context, username string) (PrivateUser, error)

Self gets the current user's private data.

func (*Queries) TokenExists

func (q *Queries) TokenExists(ctx context.Context, token string) (int64, error)

TokenExists returns 1 if the token exists or 0.

func (*Queries) UnlikePost

func (q *Queries) UnlikePost(ctx context.Context, arg UnlikePostParams) error

UnlikePost removes a like of the current user from a post.

func (*Queries) UpdateUser

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

func (*Queries) User

func (q *Queries) User(ctx context.Context, username string) (PublicUser, error)

User gets any user's public data.

func (*Queries) UserPasshash

func (q *Queries) UserPasshash(ctx context.Context, username string) ([]byte, error)

UserPasshash gets a user's password hash.

func (*Queries) ValidateSession

func (q *Queries) ValidateSession(ctx context.Context, token string) (ValidateSessionRow, error)

ValidateSession validates the session and returns the username. An error is returned if the session doesn't exist anymore.

func (*Queries) WithTx

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

type Session

type Session struct {
	Token    string
	Username string
	Expiry   time.Time
	Metadata json.RawMessage
}

type UnlikePostParams

type UnlikePostParams struct {
	PostID   int64
	Username string
}

type UpdateUserParams

type UpdateUserParams struct {
	Username        string
	DisplayName     sql.NullString
	Avatar          sql.NullString
	Bio             sql.NullString
	Birthday        sql.NullTime
	FoodPreferences json.RawMessage
}

type User

type User struct {
	Username        string
	Passhash        []byte
	DisplayName     sql.NullString
	Avatar          sql.NullString
	Bio             sql.NullString
	Birthday        sql.NullTime
	FoodPreferences json.RawMessage
}

type ValidateSessionRow

type ValidateSessionRow struct {
	Username string
	Expiry   time.Time
	Metadata json.RawMessage
}

Jump to

Keyboard shortcuts

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