db

package
v0.0.0-...-f97eb1b Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateNotebookParams

type CreateNotebookParams struct {
	ID        uuid.UUID `json:"id"`
	Title     string    `json:"title"`
	Topic     string    `json:"topic"`
	Content   string    `json:"content"`
	UserID    uuid.UUID `json:"user_id"`
	CreatedAt time.Time `json:"created_at"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID           uuid.UUID `json:"id"`
	UserID       uuid.UUID `json:"user_id"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type CreateUserParams

type CreateUserParams struct {
	ID       uuid.UUID `json:"id"`
	Username string    `json:"username"`
	Email    string    `json:"email"`
	Password string    `json:"password"`
}

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 DeleteNotebookParams

type DeleteNotebookParams struct {
	ID           uuid.UUID `json:"id"`
	UserID       uuid.UUID `json:"user_id"`
	LastModified time.Time `json:"last_modified"`
}

type GetNotebookParams

type GetNotebookParams struct {
	ID     uuid.UUID `json:"id"`
	UserID uuid.UUID `json:"user_id"`
}

type GetNotebookTitlesByTopicParams

type GetNotebookTitlesByTopicParams struct {
	UserID uuid.UUID `json:"user_id"`
	Topic  string    `json:"topic"`
}

type GetNotebookTitlesByTopicRow

type GetNotebookTitlesByTopicRow struct {
	ID    uuid.UUID `json:"id"`
	Title string    `json:"title"`
}

type ListNotebooksParams

type ListNotebooksParams struct {
	UserID uuid.UUID `json:"user_id"`
	Limit  int32     `json:"limit"`
	Offset int32     `json:"offset"`
}

type ListTopicsParams

type ListTopicsParams struct {
	UserID uuid.UUID `json:"user_id"`
	Topic  string    `json:"topic"`
}

type Notebook

type Notebook struct {
	ID           uuid.UUID `json:"id"`
	Title        string    `json:"title"`
	Topic        string    `json:"topic"`
	Content      string    `json:"content"`
	Deleted      bool      `json:"deleted"`
	LastModified time.Time `json:"last_modified"`
	CreatedAt    time.Time `json:"created_at"`
	UserID       uuid.UUID `json:"user_id"`
}

type Querier

type Querier interface {
	CreateNotebook(ctx context.Context, arg CreateNotebookParams) (Notebook, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	DeleteNotebook(ctx context.Context, arg DeleteNotebookParams) (Notebook, error)
	GetNotebook(ctx context.Context, arg GetNotebookParams) (Notebook, error)
	GetNotebookTitlesByTopic(ctx context.Context, arg GetNotebookTitlesByTopicParams) ([]GetNotebookTitlesByTopicRow, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	GetUserByEmail(ctx context.Context, email string) (User, error)
	GetUserById(ctx context.Context, id uuid.UUID) (User, error)
	ListNotebooks(ctx context.Context, arg ListNotebooksParams) ([]Notebook, error)
	ListTopics(ctx context.Context, arg ListTopicsParams) ([]string, error)
	SearchNotebooks(ctx context.Context, arg SearchNotebooksParams) ([]Notebook, error)
	UpdateNotebook(ctx context.Context, arg UpdateNotebookParams) (Notebook, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateNotebook

func (q *Queries) CreateNotebook(ctx context.Context, arg CreateNotebookParams) (Notebook, error)

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) (User, error)

func (*Queries) DeleteNotebook

func (q *Queries) DeleteNotebook(ctx context.Context, arg DeleteNotebookParams) (Notebook, error)

func (*Queries) GetNotebook

func (q *Queries) GetNotebook(ctx context.Context, arg GetNotebookParams) (Notebook, error)

func (*Queries) GetNotebookTitlesByTopic

func (q *Queries) GetNotebookTitlesByTopic(ctx context.Context, arg GetNotebookTitlesByTopicParams) ([]GetNotebookTitlesByTopicRow, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error)

func (*Queries) GetUserByEmail

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

func (*Queries) GetUserById

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

func (*Queries) ListNotebooks

func (q *Queries) ListNotebooks(ctx context.Context, arg ListNotebooksParams) ([]Notebook, error)

func (*Queries) ListTopics

func (q *Queries) ListTopics(ctx context.Context, arg ListTopicsParams) ([]string, error)

func (*Queries) SearchNotebooks

func (q *Queries) SearchNotebooks(ctx context.Context, arg SearchNotebooksParams) ([]Notebook, error)

func (*Queries) UpdateNotebook

func (q *Queries) UpdateNotebook(ctx context.Context, arg UpdateNotebookParams) (Notebook, error)

func (*Queries) WithTx

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

type SQLStorage

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

type SearchNotebooksParams

type SearchNotebooksParams struct {
	UserID uuid.UUID `json:"user_id"`
	Title  string    `json:"title"`
}

type Session

type Session struct {
	ID           uuid.UUID `json:"id"`
	UserID       uuid.UUID `json:"user_id"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type Storage

type Storage interface {
	Querier
}

func NewStorage

func NewStorage(database *sql.DB) Storage

type UpdateNotebookParams

type UpdateNotebookParams struct {
	ID           uuid.UUID `json:"id"`
	UserID       uuid.UUID `json:"user_id"`
	Title        string    `json:"title"`
	Content      string    `json:"content"`
	Topic        string    `json:"topic"`
	LastModified time.Time `json:"last_modified"`
}

type User

type User struct {
	ID                uuid.UUID `json:"id"`
	Username          string    `json:"username"`
	Email             string    `json:"email"`
	Password          string    `json:"password"`
	Suspended         bool      `json:"suspended"`
	CreatedAt         time.Time `json:"created_at"`
	PasswordChangedAt time.Time `json:"password_changed_at"`
}

Jump to

Keyboard shortcuts

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