monolayer / schema / PgDatabase
Class: PgDatabase
Properties
Property | Modifier | Type | Description |
---|---|---|---|
camelCase | readonly | boolean | Whether to convert camelCase column names to snake_case column names in the database. Default false |
extensions | readonly | PgExtension [] | Extensions to install in the database. Default [] |
generatePrismaSchema | readonly | boolean | Whether to generate a Prisma schema for the database after running migrations. Default false |
id | readonly | string | Id of the database. |
prismaSchemaPath | readonly | string | Path to the Prisma schema to use when generating. Default "prisma/schema.prisma" |
schemas | readonly | AnySchema [] | 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