Documentation
¶
Overview ¶
Package lofidb is a small database browser that renders Bulma-styled HTML for a *sql.DB. It works against PostgreSQL natively and against pglike (codeberg.org/hum3/go-postgres) — the same SQL runs unchanged on both because pglike installs PG-compatible catalog views.
Two modes of consumption:
- Server mode: http.Handler from HTTPHandler() mounted under URLPrefix.
- WASM mode: call IndexHTML / TableHTML and pipe the strings into your existing rendering pipeline (e.g. lofigui.HTML()).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPHandler ¶
HTTPHandler returns an http.Handler that serves the explorer UI. It mounts at opts.URLPrefix; the index is served at the prefix itself and individual tables at "<prefix>/<table>". The handler does not impose authentication — wrap it with whatever middleware your application already uses.
func IndexHTML ¶
IndexHTML renders the explorer landing page: the list of tables with row/column counts and a relationship summary. The result is HTML fragment (no <html>/<body> wrapper) suitable for embedding inside a host page.
Types ¶
type Column ¶
type Column struct {
Name string
DataType string
Nullable string // "YES" or "NO"
Default *string // nil if no default
Position int // 1-based ordinal_position
}
Column describes a single column from information_schema.columns.
type ForeignKey ¶
type ForeignKey struct {
From, FromCol string
To, ToCol string // RefTable / RefCol below; To/ToCol kept for clarity
RefTable, RefCol string
OnUpdate, OnDelete string
}
ForeignKey describes one column's FK relationship.
type Options ¶
type Options struct {
// Schema is the database schema to browse. Defaults to "public", which is
// what pglike's catalog views report and the default schema for most PG
// installations.
Schema string
// URLPrefix is the path under which the explorer is mounted. Links emitted
// by the HTML builders use this prefix. Defaults to "/explorer".
// Must not end with a trailing slash.
URLPrefix string
// PageSize is the number of rows per page in table-detail views. Default 50.
PageSize int
// HideTables lists tables that should not be shown. Internal tables
// (sqlite_*, pglike helpers) are always hidden in addition to this list.
HideTables []string
}
Options controls the explorer's behaviour. The zero value is valid; missing fields are filled in from defaults.