Documentation
¶
Overview ¶
Package notes is an example custom app demonstrating the burrow framework.
Index ¶
- type App
- func (a *App) AdminNavItems() []burrow.NavItem
- func (a *App) AdminRoutes(r chi.Router)
- func (a *App) Dependencies() []string
- func (a *App) FuncMap() template.FuncMap
- func (a *App) MigrationFS() fs.FS
- func (a *App) Name() string
- func (a *App) NavItems() []burrow.NavItem
- func (a *App) Register(cfg *burrow.AppConfig) error
- func (a *App) Routes(r chi.Router)
- func (a *App) TemplateFS() fs.FS
- func (a *App) TranslationFS() fs.FS
- type Handlers
- func (h *Handlers) Create(w http.ResponseWriter, r *http.Request) error
- func (h *Handlers) Delete(w http.ResponseWriter, r *http.Request) error
- func (h *Handlers) Edit(w http.ResponseWriter, r *http.Request) error
- func (h *Handlers) List(w http.ResponseWriter, r *http.Request) error
- func (h *Handlers) New(w http.ResponseWriter, r *http.Request) error
- func (h *Handlers) 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 int64) error
- func (r *Repository) GetByID(ctx context.Context, noteID, userID int64) (*Note, error)
- func (r *Repository) ListByUserID(ctx context.Context, userID int64) ([]Note, error)
- func (r *Repository) ListByUserIDPaged(ctx context.Context, userID int64, pr burrow.PageRequest) ([]Note, burrow.PageResult, error)
- func (r *Repository) SearchByUserID(ctx context.Context, userID int64, 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 ¶
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 (*App) AdminNavItems ¶
func (*App) AdminRoutes ¶
func (*App) Dependencies ¶
func (*App) MigrationFS ¶
func (*App) TemplateFS ¶
TemplateFS returns the embedded HTML template files.
func (*App) TranslationFS ¶
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers holds the notes HTTP handlers.
func (*Handlers) Edit ¶ added in v0.4.0
Edit renders the edit form pre-filled with 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
GetByID returns a single note by ID, scoped to the given user.
func (*Repository) ListByUserID ¶
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.