Data & Persistence
Edit one schema file, run one generate, and every consumer follows — the typed Prisma
client, the matching zod validation schemas, and the migration all come out of the same
netscript db workflow. That matters most when the one doing the editing is an AI agent:
persistence is where a generated backend usually drifts, because a model change normally
fans out into separate client, validation, and migration updates — each one a turn that
can be missed. NetScript folds those into one cycle.
The pillar splits state along one line. Records — durable, relational, queried with a typed client — live in the database layer, where every plugin contributes its own models to the same datasource. Execution state — caches, sessions, work queues, scheduled ticks — lives in KV, queues & cron, provider-agnostic packages that run on zero-config local backends until Aspire provisions the production ones. The scaffold uses both from day one: Postgres for records, Redis/KV for execution state.
Start here when the question is where state lives, how schema changes ship, or how the workspace resolves a second database.
The persistence layer behind services, queues, and workflow state.
Quickstart Data contractsFollow the Storefront data step before service and saga work expand it.
How-To Database and migrationInitialize and migrate the primary datasource.
How-To Second databaseAdd and address another datasource from the workspace.
API Reference databaseGenerated database package symbols.
API Reference kv and Prisma adapterGenerated KV and adapter package symbols.
Learn, do, look up
Cart contracts back a real database schema from chapter 3 on.
Do RecipesTask-oriented recipes for this area, one problem each.
Look up `@netscript/database` referenceGenerated API reference. Related units: `kv`, `prisma-adapter-mysql`.
Understand ArchitectureThe design rationale behind this pillar.