Skip to content

monolayer / schema / PgDatabase

Class: PgDatabase

Properties

PropertyModifierTypeDescription
camelCasereadonlybooleanWhether to convert camelCase column names to snake_case column names in the database. Default false
extensionsreadonlyPgExtension[]Extensions to install in the database. Default []
generatePrismaSchemareadonlybooleanWhether to generate a Prisma schema for the database after running migrations. Default false
idreadonlystringId of the database.
prismaSchemaPathreadonlystringPath to the Prisma schema to use when generating. Default "prisma/schema.prisma"
schemasreadonlyAnySchema[]Schemas in the database. Default []
seeder?readonly(db: Kysely<any>) => Promise<void>Function to seed the database with data.

Accessors

connectionString

get connectionString(): string

Get the connection string for the database.

It will fetch he connection string from by inferring the environment variable in the following format:

MONO_PG_${DATABASE_ID_TO_UPPER_CASE_AND_SNAKE_CASE}_DATABASE_URL.

Example

For the following database:

ts
const db = defineDatabase({
	id: "my-db",
	schemas: [],
});

The connection string will be fetched from the environment variable: MONO_PG_MY_DB_DATABASE_URL

Returns

string