notes

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: EUPL-1.2 Imports: 20 Imported by: 0

Documentation

Overview

Package notes is an example custom app demonstrating the burrow framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App implements the notes contrib app.

func New

func New() *App

New creates a new notes app.

func (*App) AdminNavItems

func (a *App) AdminNavItems() []burrow.NavItem

func (*App) AdminRoutes

func (a *App) AdminRoutes(r chi.Router)

func (*App) Dependencies

func (a *App) Dependencies() []string

func (*App) FuncMap

func (a *App) FuncMap() template.FuncMap

FuncMap returns template functions used by notes templates.

func (*App) MigrationFS

func (a *App) MigrationFS() fs.FS

func (*App) Name

func (a *App) Name() string

func (*App) NavItems

func (a *App) NavItems() []burrow.NavItem

func (*App) Register

func (a *App) Register(cfg *burrow.AppConfig) error

func (*App) Routes

func (a *App) Routes(r chi.Router)

func (*App) TemplateFS

func (a *App) TemplateFS() fs.FS

TemplateFS returns the embedded HTML template files.

func (*App) TranslationFS

func (a *App) TranslationFS() fs.FS

type Handlers

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

Handlers holds the notes HTTP handlers.

func NewHandlers

func NewHandlers(repo *Repository) *Handlers

NewHandlers creates notes handlers.

func (*Handlers) Create

func (h *Handlers) Create(w http.ResponseWriter, r *http.Request) error

Create adds a new note for the authenticated user.

func (*Handlers) Delete

func (h *Handlers) Delete(w http.ResponseWriter, r *http.Request) error

Delete removes a note owned by the authenticated user.

func (*Handlers) Edit added in v0.4.0

func (h *Handlers) Edit(w http.ResponseWriter, r *http.Request) error

Edit renders the edit form pre-filled with an existing note.

func (*Handlers) List

func (h *Handlers) List(w http.ResponseWriter, r *http.Request) error

List renders the user's notes as an HTML page with cursor-based pagination.

func (*Handlers) New added in v0.4.0

func (h *Handlers) New(w http.ResponseWriter, r *http.Request) error

New renders the empty create form. HTMX: returns the form fragment for inline insertion. Non-HTMX: returns the form wrapped in the layout.

func (*Handlers) Update added in v0.4.0

func (h *Handlers) Update(w http.ResponseWriter, r *http.Request) error

Update binds, validates, and updates an existing note.

type Note

type Note struct {
	bun.BaseModel `bun:"table:notes,alias:n"`

	ID        int64     `bun:",pk,autoincrement" json:"id" verbose:"ID"`
	UserID    int64     `bun:",notnull" json:"user_id" form:"-" verbose:"User ID"`
	Title     string    `bun:",notnull" json:"title" verbose:"Title" form:"title" validate:"required"`
	Content   string    `bun:",notnull,default:''" json:"content" verbose:"Content" form:"content" widget:"textarea"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"created_at" form:"-" verbose:"Created at"`
	DeletedAt time.Time `bun:",soft_delete,nullzero" json:"-" form:"-"`
}

Note represents a user's note.

type Repository

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

Repository provides data access for notes.

func NewRepository

func NewRepository(db *bun.DB) *Repository

NewRepository creates a new notes repository.

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, note *Note) error

Create inserts a new note.

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, noteID, userID int64) error

Delete soft-deletes a note owned by the given user.

func (*Repository) GetByID added in v0.4.0

func (r *Repository) GetByID(ctx context.Context, noteID, userID int64) (*Note, error)

GetByID returns a single note by ID, scoped to the given user.

func (*Repository) ListByUserID

func (r *Repository) ListByUserID(ctx context.Context, userID int64) ([]Note, error)

ListByUserID returns all notes for a user, most recent first.

func (*Repository) ListByUserIDPaged

func (r *Repository) ListByUserIDPaged(ctx context.Context, userID int64, pr burrow.PageRequest) ([]Note, burrow.PageResult, error)

ListByUserIDPaged returns paginated notes for a user using cursor-based pagination. Notes are ordered by ID descending (newest first).

func (*Repository) SearchByUserID

func (r *Repository) SearchByUserID(ctx context.Context, userID int64, query string, pr burrow.PageRequest) ([]Note, burrow.PageResult, error)

SearchByUserID performs a full-text search across notes for a user using FTS5. Results are ordered by ID descending (newest first) with cursor-based pagination. Returns empty results for empty queries or FTS5 syntax errors.

func (*Repository) Update added in v0.4.0

func (r *Repository) Update(ctx context.Context, note *Note) error

Update updates an existing note.

Jump to

Keyboard shortcuts

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