notes

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = den.ErrNotFound

ErrNotFound is returned when a note is not found.

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)

AdminRoutes registers admin routes for notes management.

func (*App) Configure added in v0.10.0

func (a *App) Configure(cfg *burrow.AppConfig, _ *cli.Command) error

func (*App) Create added in v0.11.0

func (a *App) Create(w http.ResponseWriter, r *http.Request) error

Create adds a new note for the authenticated user.

func (*App) Delete added in v0.11.0

func (a *App) Delete(w http.ResponseWriter, r *http.Request) error

Delete removes a note owned by the authenticated user.

func (*App) Dependencies

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

func (*App) Documents added in v0.11.0

func (a *App) Documents() []any

Documents returns the Den document types registered by this app.

func (*App) Edit added in v0.11.0

func (a *App) Edit(w http.ResponseWriter, r *http.Request) error

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

func (*App) List added in v0.11.0

func (a *App) List(w http.ResponseWriter, r *http.Request) error

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

func (*App) Name

func (a *App) Name() string

func (*App) NavItems

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

func (*App) New added in v0.11.0

func (a *App) 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 (*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

func (*App) Update added in v0.11.0

func (a *App) Update(w http.ResponseWriter, r *http.Request) error

Update binds, validates, and updates an existing note.

type Note

type Note struct {
	document.Base
	UserID  string `json:"user_id" den:"index" form:"-" verbose:"User ID"`
	Title   string `json:"title" den:"index,fts" verbose:"Title" form:"title" validate:"required"`
	Content string `json:"content" den:"fts" verbose:"Content" form:"content" widget:"textarea"`
}

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 *den.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 string) error

Delete deletes a note owned by the given user.

func (*Repository) DeleteByID added in v0.13.0

func (r *Repository) DeleteByID(ctx context.Context, noteID string) error

DeleteByID deletes a note by ID (no user scope, for admin).

func (*Repository) GetByID added in v0.4.0

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

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

func (*Repository) ListAllPaged added in v0.13.0

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

ListAllPaged returns all notes with pagination (no user scope, for admin).

func (*Repository) ListByUserID

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

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

func (*Repository) ListByUserIDPaged

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

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

func (*Repository) SearchByUserID

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

SearchByUserID performs a full-text search across notes for a user. Results are ordered by created_at descending (newest first) with offset-based pagination. Returns empty results for empty queries.

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