Documentation
¶
Overview ¶
Package notes is an example custom app demonstrating the burrow framework.
Index ¶
- Variables
- type App
- func (a *App) AdminNavItems() []burrow.NavItem
- func (a *App) AdminRoutes(r chi.Router)
- func (a *App) Configure(cfg *burrow.AppConfig, _ *cli.Command) error
- func (a *App) Create(w http.ResponseWriter, r *http.Request) error
- func (a *App) Delete(w http.ResponseWriter, r *http.Request) error
- func (a *App) Dependencies() []string
- func (a *App) Documents() []any
- func (a *App) Edit(w http.ResponseWriter, r *http.Request) error
- func (a *App) List(w http.ResponseWriter, r *http.Request) error
- func (a *App) Name() string
- func (a *App) NavItems() []burrow.NavItem
- func (a *App) New(w http.ResponseWriter, r *http.Request) error
- func (a *App) Routes(r chi.Router)
- func (a *App) TemplateFS() fs.FS
- func (a *App) TranslationFS() fs.FS
- func (a *App) Update(w http.ResponseWriter, r *http.Request) error
- type Note
- type Repository
- func (r *Repository) Create(ctx context.Context, note *Note) error
- func (r *Repository) Delete(ctx context.Context, noteID, userID string) error
- func (r *Repository) DeleteByID(ctx context.Context, noteID string) error
- func (r *Repository) GetByID(ctx context.Context, noteID, userID string) (*Note, error)
- func (r *Repository) ListAllPaged(ctx context.Context, pr burrow.PageRequest) ([]Note, burrow.PageResult, error)
- func (r *Repository) ListByUserID(ctx context.Context, userID string) ([]Note, error)
- func (r *Repository) ListByUserIDPaged(ctx context.Context, userID string, pr burrow.PageRequest) ([]Note, burrow.PageResult, error)
- func (r *Repository) SearchByUserID(ctx context.Context, userID string, query string, pr burrow.PageRequest) ([]Note, burrow.PageResult, error)
- func (r *Repository) Update(ctx context.Context, note *Note) error
Constants ¶
This section is empty.
Variables ¶
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 (*App) AdminNavItems ¶
func (*App) AdminRoutes ¶
AdminRoutes registers admin routes for notes management.
func (*App) Dependencies ¶
func (*App) Documents ¶ added in v0.11.0
Documents returns the Den document types registered by this app.
func (*App) List ¶ added in v0.11.0
List renders the user's notes as an HTML page with offset-based pagination.
func (*App) New ¶ added in v0.11.0
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) TemplateFS ¶
TemplateFS returns the embedded HTML template files.
func (*App) TranslationFS ¶
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
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 ¶
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.