Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt

Use this file to discover all available pages before exploring further.

PostgresResource connects to Postgres via a DSN and exposes its schemas and tables as a tree. Setup steps for the DSN and required permissions live at Postgres Credentials.

Node

pnpm add @struktoai/mirage-node pg
import { MountMode, PostgresResource, Workspace } from '@struktoai/mirage-node'

const pg = new PostgresResource({
  dsn: process.env.PG_DSN!,
  schemas: ['public', 'analytics'],
})

const ws = new Workspace({ '/pg': pg }, { mode: MountMode.READ })
await ws.execute('ls /pg/public/')

Browser

pnpm add @struktoai/mirage-browser
For browser apps, point the resource at a same-origin proxy or use a serverless Postgres driver such as @neondatabase/serverless. The browser examples include a Vite plugin that wires the resource to a server-side pg client:
import { MountMode, PostgresResource, Workspace } from '@struktoai/mirage-browser'

const pg = new PostgresResource({
  dsn: 'postgres-proxy://app',
})

Config

FieldDefaultNotes
dsnrequiredPostgres connection string. Redacted in snapshots.
schemasnoneOptional list to limit which schemas appear in the tree.
defaultRowLimit1000Default LIMIT applied to ad-hoc reads.
maxReadRows10_000Hard ceiling per read.
maxReadBytes10 MiBHard ceiling per read.
defaultSearchLimit100Default LIMIT for search-style queries.

Mount mode

read only. Postgres mounts are read-only at the resource level.

Snapshot behavior

The DSN is redacted on snapshot. Loading a snapshot back requires an override config that supplies a fresh DSN.