QUESTPIE
Operate in Production

Database

PostgreSQL with Drizzle ORM — schema generation, raw queries, and transactions.

QUESTPIE uses PostgreSQL with Drizzle ORM. The database schema is generated from your collection and global definitions.

Configuration

questpie.config.ts
export default runtimeConfig({
	db: {
		url: process.env.DATABASE_URL || "postgres://localhost/myapp",
	},
});

Schema Generation

Codegen produces Drizzle table definitions from your collections. Each field maps to a column type:

FieldDrizzle Column
f.text()varchar / text
f.number()integer
f.boolean()boolean
f.date()date
f.datetime()timestamp
f.select()varchar
f.json()jsonb
f.object()jsonb
f.array()jsonb
f.relation()varchar (FK)

Raw Database Access

Access Drizzle directly through the db context:

handler: async ({ db }) => {
	const result = await db.execute(sql`
    SELECT COUNT(*) as total FROM appointments
    WHERE status = 'completed'
  `);
	return result;
};

Indexes

Define indexes on collections:

import { uniqueIndex, index } from "drizzle-orm/pg-core";

.indexes(({ table }) => [
  uniqueIndex("posts_slug_unique").on(table.slug),
  index("posts_status_idx").on(table.status),
])

On this page