Artifact 5486f0e4d6bea8f32354ce251d37fb5fa5e3d02c213b63e9f9b297db25b6ae47:
- File
docs/site/content/docs/reference/sdk/db/api.md
— part of check-in
[e2a2f28861]
at
2026-04-26 07:52:11
on branch trunk
— docs site + landing + Cloudflare auto-deploy (#6)
* design: docs site + landing page + Cloudflare auto-deploy
Mirror dagnats's docs/landing infrastructure for libfossil: a single-page landing at site/index.html (forked CSS/HTML, content rewritten), a Hugo + Hextra docs site at docs/site/, gomarkdoc-generated SDK reference under docs/site/content/docs/reference/sdk/, llms.txt artifacts, and a wrangler.jsonc that lets Cloudflare's git integration auto-deploy on push to main. Existing docs/*.md files move under docs/site/content/docs/.
* design: correct landing-page path to Hugo layout override
dagnats's working landing page lives at docs/site/layouts/index.html (a Hugo home-page layout override), not at site/index.html. The top-level site/index.html in dagnats is an older draft that the build pipeline ignores. Match the working setup.
* design: align visual system + section list with live dagnats landing
The earlier description came from dagnats's stale top-level site/index.html (JetBrains Mono + Instrument Serif italic + ember/teal accents, 8 sections). The live Hugo layout that actually serves at / uses Geist Mono only, prefers-color-scheme dual-mode (warm cream / warm dark), a single ember accent, and 7 sections (Install, What it is, Why you might want it, How it fits together, Compared to neighbors, What it is not, Get going). Update the spec to match what we are actually mirroring.
* design: drop SDK regen from CF build to match dagnats exactly
Earlier draft had CF install Go + gomarkdoc and re-run docs-gen-sdk on every deploy. dagnats does not do that; it relies on the pre-commit hook to keep committed SDK pages in sync, and ships only Hugo + llms-gen + hugo --minify in the CF build. Match that: smaller, faster CF build, no Go-runtime assumption about Workers Builds, and a true 1:1 mirror.
* plan: docs site + landing + CF auto-deploy implementation steps
11 tasks covering Hugo+Hextra bootstrap, content moves, gomarkdoc SDK generation with pre-commit drift check, llms.txt artifacts, Makefile targets, landing page fork from dagnats's live Hugo home layout, wrangler.jsonc for CF Workers Static Assets, README update, and PR creation.
* docs(site): bootstrap Hugo + Hextra skeleton
* docs(site): move existing docs into Hugo content tree
* docs(site): fix links + H1s broken by docs-tree move
- Drop .md extensions on Hugo cross-doc links - Switch source-code references to absolute github.com/danmestas/libfossil URLs (relative ../ paths broke when files moved 3 dirs deeper) - Align H1 of architecture.md and migration-from-fossil.md with their frontmatter titles
* docs(site): add quickstart, examples, and SDK section stubs
* docs(site): tighten quickstart snippets + reference index
- Make the Sync example self-contained (open + sync, full main, real signatures) - Bridge from Clone to Open with a one-line prose link - Add a sentence to reference/_index.md so it does not render blank - Use the project's canonical "pure-Go, CGo-free" phrasing
* docs(site): add docs-gen-sdk Makefile target + commit generated SDK pages
* docs(site): pin gomarkdoc version + replace empty driver stubs with prose
- Add GOMARKDOC_VERSION Makefile variable so contributors don't drift on output format when a new gomarkdoc ships - Drop the two driver packages (modernc, ncruces) from gomarkdoc and hand-write _index.md pages explaining the register-on-import contract; the stubs were byte-stable but rendered as visibly broken documentation
* docs(site): add gen-llms-txt.sh + docs-gen-llms target
* docs(site): switch llms-full frontmatter strip from sed to awk
The sed range-negation pattern '/^---$/,/^---$/!p' silently re-opens a suppression range on any bare '---' in body content, eating Markdown horizontal rules and embedded YAML in fenced code blocks. The awk pattern strips the frontmatter only when it begins on line 1, leaving body content intact regardless of how many '---' lines it contains.
* hooks: pre-commit fails when SDK pages drift from code
* hooks: pre-commit re-installs gomarkdoc if it's the wrong version
The drift check's existing gate just looks for gomarkdoc on PATH. A contributor with an older gomarkdoc installed locally would have the gate pass and then run regeneration with their stale binary, producing either a silent false-negative or a confusing OUT-OF-DATE error with no version hint. Compare the installed version against GOMARKDOC_VERSION from Makefile and re-install on mismatch. Best-effort; offline contributors can still commit.
* docs(site): add docs-serve, docs-build, docs aggregate targets
* docs(site): make docs aggregate parallel-safe via explicit deps
The docs aggregate previously listed gen-sdk, gen-llms, and build as side-by-side prereqs. Make doesn't guarantee left-to-right ordering under -j, and gen-llms reads what gen-sdk writes, while build reads both. Encode the chain explicitly so 'make -j docs' is correct. Side benefit: 'make docs-build' standalone now produces a complete deployable site, matching contributor expectation.
* site(landing): fork dagnats home layout; rebrand chrome
* site(landing): rewrite §01–§07 content for libfossil
* site(landing): use .ascii class for diagram + fix §03 phrasing
* deploy: add wrangler.jsonc for CF Workers Static Assets
* docs: point README at the new docs site (user: [email protected], size: 7790) [annotate] [blame] [check-ins using]
<!-- Code generated by gomarkdoc. DO NOT EDIT --> # db ```go import "github.com/danmestas/libfossil/db" ``` Package db provides a SQLite database layer with pluggable drivers. Two SQLite drivers ship with libfossil — modernc \(pure Go, default\) and ncruces \(WASM\-capable\). Select one at build time by importing its driver package: ``` import _ "github.com/danmestas/libfossil/db/driver/modernc" ``` [Open](<#Open>) and [OpenWith](<#OpenWith>) handle DSN construction, WAL/pragma setup, and WASM\-specific workarounds. Use [DB.WithTx](<#DB.WithTx>) for transaction scoping with automatic rollback on error. The [Querier](<#Querier>) interface \(Exec, QueryRow, Query\) is satisfied by both [DB](<#DB>) and [Tx](<#Tx>), allowing callers to write transaction\-agnostic code. ## Index - [func CreateRepoSchema\(d \*DB\) error](<#CreateRepoSchema>) - [func DefaultPragmas\(\) map\[string\]string](<#DefaultPragmas>) - [func Register\(cfg DriverConfig\)](<#Register>) - [func ScanInt\(v any\) \(int, bool\)](<#ScanInt>) - [func ScanJulianDay\(v any\) \(float64, bool\)](<#ScanJulianDay>) - [func ScanTime\(v any\) \(time.Time, bool\)](<#ScanTime>) - [func SeedConfig\(d \*DB, rng simio.Rand\) error](<#SeedConfig>) - [func SeedNobody\(d \*DB, caps string\) error](<#SeedNobody>) - [func SeedUser\(d \*DB, login string\) error](<#SeedUser>) - [type DB](<#DB>) - [func Open\(path string\) \(\*DB, error\)](<#Open>) - [func OpenWith\(path string, cfg OpenConfig\) \(\*DB, error\)](<#OpenWith>) - [func \(d \*DB\) ApplicationID\(\) \(int32, error\)](<#DB.ApplicationID>) - [func \(d \*DB\) Close\(\) error](<#DB.Close>) - [func \(d \*DB\) Driver\(\) string](<#DB.Driver>) - [func \(d \*DB\) Exec\(query string, args ...any\) \(sql.Result, error\)](<#DB.Exec>) - [func \(d \*DB\) Path\(\) string](<#DB.Path>) - [func \(d \*DB\) Query\(query string, args ...any\) \(\*sql.Rows, error\)](<#DB.Query>) - [func \(d \*DB\) QueryRow\(query string, args ...any\) \*sql.Row](<#DB.QueryRow>) - [func \(d \*DB\) SetApplicationID\(id int32\) error](<#DB.SetApplicationID>) - [func \(d \*DB\) SqlDB\(\) \*sql.DB](<#DB.SqlDB>) - [func \(d \*DB\) WithTx\(fn func\(tx \*Tx\) error\) error](<#DB.WithTx>) - [type DriverConfig](<#DriverConfig>) - [func RegisteredDriver\(\) \*DriverConfig](<#RegisteredDriver>) - [type OpenConfig](<#OpenConfig>) - [type Querier](<#Querier>) - [type Tx](<#Tx>) - [func \(t \*Tx\) Exec\(query string, args ...any\) \(sql.Result, error\)](<#Tx.Exec>) - [func \(t \*Tx\) Query\(query string, args ...any\) \(\*sql.Rows, error\)](<#Tx.Query>) - [func \(t \*Tx\) QueryRow\(query string, args ...any\) \*sql.Row](<#Tx.QueryRow>) <a name="CreateRepoSchema"></a> ## func CreateRepoSchema ```go func CreateRepoSchema(d *DB) error ``` <a name="DefaultPragmas"></a> ## func DefaultPragmas ```go func DefaultPragmas() map[string]string ``` DefaultPragmas returns the default pragma settings. <a name="Register"></a> ## func Register ```go func Register(cfg DriverConfig) ``` Register registers a SQLite driver for use by Open/OpenWith. Must be called exactly once \(typically from a driver package's init\(\)\). Panics if called more than once. <a name="ScanInt"></a> ## func ScanInt ```go func ScanInt(v any) (int, bool) ``` ScanInt converts a scanned value to int. SQLite drivers differ on BOOLEAN columns: modernc returns int64, ncruces returns bool. Scan the column into an \`any\` variable, then pass it here. <a name="ScanJulianDay"></a> ## func ScanJulianDay ```go func ScanJulianDay(v any) (float64, bool) ``` ScanJulianDay converts a scanned mtime value to a float64 Julian Day Number. SQLite drivers return mtime differently: modernc returns float64, ncruces returns time.Time for DATETIME/TIMESTAMP/DATE columns. Scan the column into an \`any\` variable, then pass it here. <a name="ScanTime"></a> ## func ScanTime ```go func ScanTime(v any) (time.Time, bool) ``` ScanTime converts a scanned mtime value to time.Time. Same driver\-compatibility rationale as ScanJulianDay. <a name="SeedConfig"></a> ## func SeedConfig ```go func SeedConfig(d *DB, rng simio.Rand) error ``` <a name="SeedNobody"></a> ## func SeedNobody ```go func SeedNobody(d *DB, caps string) error ``` SeedNobody inserts a "nobody" user with the given capabilities. This controls anonymous access policy for the repo. <a name="SeedUser"></a> ## func SeedUser ```go func SeedUser(d *DB, login string) error ``` <a name="DB"></a> ## type DB DB wraps a SQLite database connection. ```go type DB struct { // contains filtered or unexported fields } ``` <a name="Open"></a> ### func Open ```go func Open(path string) (*DB, error) ``` Open opens a SQLite database with the registered driver and default pragmas. <a name="OpenWith"></a> ### func OpenWith ```go func OpenWith(path string, cfg OpenConfig) (*DB, error) ``` OpenWith opens a SQLite database with explicit configuration. <a name="DB.ApplicationID"></a> ### func \(\*DB\) ApplicationID ```go func (d *DB) ApplicationID() (int32, error) ``` <a name="DB.Close"></a> ### func \(\*DB\) Close ```go func (d *DB) Close() error ``` <a name="DB.Driver"></a> ### func \(\*DB\) Driver ```go func (d *DB) Driver() string ``` <a name="DB.Exec"></a> ### func \(\*DB\) Exec ```go func (d *DB) Exec(query string, args ...any) (sql.Result, error) ``` <a name="DB.Path"></a> ### func \(\*DB\) Path ```go func (d *DB) Path() string ``` <a name="DB.Query"></a> ### func \(\*DB\) Query ```go func (d *DB) Query(query string, args ...any) (*sql.Rows, error) ``` <a name="DB.QueryRow"></a> ### func \(\*DB\) QueryRow ```go func (d *DB) QueryRow(query string, args ...any) *sql.Row ``` <a name="DB.SetApplicationID"></a> ### func \(\*DB\) SetApplicationID ```go func (d *DB) SetApplicationID(id int32) error ``` <a name="DB.SqlDB"></a> ### func \(\*DB\) SqlDB ```go func (d *DB) SqlDB() *sql.DB ``` SqlDB returns the underlying \*sql.DB connection. <a name="DB.WithTx"></a> ### func \(\*DB\) WithTx ```go func (d *DB) WithTx(fn func(tx *Tx) error) error ``` <a name="DriverConfig"></a> ## type DriverConfig DriverConfig defines a SQLite driver's name and DSN builder. ```go type DriverConfig struct { Name string BuildDSN func(path string, pragmas map[string]string) string } ``` <a name="RegisteredDriver"></a> ### func RegisteredDriver ```go func RegisteredDriver() *DriverConfig ``` RegisteredDriver returns a copy of the currently registered driver config, or nil if none. <a name="OpenConfig"></a> ## type OpenConfig OpenConfig allows callers to customize driver selection and pragmas. ```go type OpenConfig struct { Driver string // override driver name (empty = use registered driver) Pragmas map[string]string // additional/override pragmas (merged with defaults) } ``` <a name="Querier"></a> ## type Querier Querier is the common interface satisfied by both \*DB and \*Tx. Functions that need to work inside transactions accept Querier instead of \*DB. ```go type Querier interface { Exec(query string, args ...any) (sql.Result, error) QueryRow(query string, args ...any) *sql.Row Query(query string, args ...any) (*sql.Rows, error) } ``` <a name="Tx"></a> ## type Tx ```go type Tx struct { // contains filtered or unexported fields } ``` <a name="Tx.Exec"></a> ### func \(\*Tx\) Exec ```go func (t *Tx) Exec(query string, args ...any) (sql.Result, error) ``` <a name="Tx.Query"></a> ### func \(\*Tx\) Query ```go func (t *Tx) Query(query string, args ...any) (*sql.Rows, error) ``` <a name="Tx.QueryRow"></a> ### func \(\*Tx\) QueryRow ```go func (t *Tx) QueryRow(query string, args ...any) *sql.Row ``` Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)