SERVER / DATABASE / SEEDERS
Seeders
Seeders load static application data through the same Database contract used by PostgreSQL, Cloudflare D1, and Dowe Database. They are versioned source bindings, validated by the compiler, and applied once per content fingerprint and database.
1 / MENTAL MODEL
Declare data, register it, then choose when to apply it
A seeder is not a request handler and does not open its own connection. It imports the entity bindings it fills, declares static insert values, and is attached to a server-only Database configuration.
import Users from "@/server/entities/users-entity"
seeder Bootstrap
insert entity:Users value:{ id:"01ARZ3NDEKTSV4RRFFQ69G5FAV" name:"Admin" email:"admin@example.com" }
database appDb provider:"dowe"
host:env.DOWE_HOST
port:env.DOWE_PORT
account:env.DOWE_ACCOUNT
secret:env.DOWE_SECRET
name:"content"
entities:[Users]
seeders:[Bootstrap]Part | Example | Meaning |
|---|---|---|
No dataThere are no records to display | ||
2 / DOCUMENTATION CASE
Seed the Solar icon catalog
The documentation application keeps its runtime icon catalog in server/seeders/icon-catalog-seeder.dowe. The module imports the category and icon entities, inserts all 37 categories before their 7,476 icon variants, and exports one IconCatalog binding.
server/seeders/icon-catalog-seeder.dowe
import IconCategories from "@/server/entities/icon-categories-entity"
import Icons from "@/server/entities/icons-entity"
seeder IconCatalog
insert entity:IconCategories value:{ slug:"arrows" label:"Arrows" position:0 positionKey:"000" count:67 }
insert entity:IconCategories value:{ slug:"arrows-action" label:"Arrows Action" position:1 positionKey:"001" count:58 }
insert entity:Icons value:{ key:"solar:bold:alt-arrow-down" name:"alt-arrow-down" category:"arrows" style:"bold" svg:{ viewBox:"0 0 24 24" paths:[] } }The source continues with the remaining category rows and normalized SVG JSON records. The stable key such as solar:bold:alt-arrow-down is application data; Dowe may generate a separate physical id for the stored record.
Rule | What Dowe enforces |
|---|---|
No dataThere are no records to display | |
3 / SERVER CONFIGURATION
Register the seeder with its entities
Keep the seeder module separate from the Database config, then import both into the server-only handle. The order in seeders:[...] is the execution order; when a seeder depends on records from another seeder, register the prerequisite first.
import IconCategories from "@/server/entities/icon-categories-entity"
import Icons from "@/server/entities/icons-entity"
import IconCatalog from "@/server/seeders/icon-catalog-seeder"
database IconDb:
provider:"dowe"
host:env.DOWE_HOST
port:env.DOWE_PORT
account:env.DOWE_ACCOUNT
secret:env.DOWE_SECRET
name:"dowe-docs-icons"
entities:[IconCategories Icons]
seeders:[IconCatalog]Connection properties stay in server configuration. Handlers import IconDb and query the generated records; pages request only the category or icon data they need.
import IconDb from "@/server/config/database"
main
server port:8081
databases:[IconDb]The explicit main.server registry lets dowe database seeders discover IconDb without duplicating its provider, entities, or credentials.
4 / EXECUTION
Separate fast development from explicit data loading
Normal dowe dev avoids loading large seeder modules during type discovery, server validation, or inspector generation on every initial compile or hot reload. When local records are required, run the explicit command from the project root; it prepares every declared local Database and applies only pending seeders.
dowe database seedersContext | Behavior | Command |
|---|---|---|
No dataThere are no records to display | ||
Local execution never contacts the authored PostgreSQL, D1, or remote Dowe provider. In production, run dowe database migrate before deployment; pending graph nodes run first, each pending seeder and its ledger record run atomically next, and the listener opens only after both succeed.
Database connection docs