Prisma schema

If you use Prisma, Studio can scaffold screens straight from your schema.prisma - no live database connection needed at generation time. Your Prisma schema is the single source of truth, and the --from flag auto-detects it (by the .prisma extension or a model block).

Scaffold from a schema file

npx @svgrid/studio add User --from prisma/schema.prisma
npm run dev            # open /User

Given a Prisma model:

// prisma/schema.prisma
enum Role {
  ADMIN
  MEMBER
}

model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  role      Role     @default(MEMBER)
  createdAt DateTime @default(now())
}

Studio reads the fields, the @id key, and the ? (optional) markers into an EntitySchema, maps scalar types (Int/String/Boolean/DateTime/Json/...), turns enum blocks into select fields, and generates the schema module, the API route, and the screen.

If your schema defines several models, pick one:

npx @svgrid/studio add Post --from prisma/schema.prisma --table Post

Scaffold the whole app

Pass --all to generate a screen for every model, plus a nav layout and a home page linking them:

npx @svgrid/studio add --all --from prisma/schema.prisma
npm run dev            # open / and browse every model

Relations are followed across the file. A @relation navigation turns its scalar foreign-key column into a lookup that shows the related row's label:

model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int    // -> a searchable lookup on User
}

The virtual author navigation field is skipped; the stored authorId column becomes the relation field, and Studio resolves its display field from the User model (a name or title column, if present).

Connecting the data

By default the generated API route starts in-memory so the screen runs immediately. When you are ready to hit the database, regenerate with a driver (Prisma's Postgres, for example):

npx @svgrid/studio add User --from prisma/schema.prisma --db postgres

...or keep your PrismaClient and wire the generated EntitySchema to a data source by hand - the schema + grid + form stay the same.

Notes

See also