Skip to content

Instantly share code, notes, and snippets.

View jordiup's full-sized avatar
🙌
Building The Future Of Digital Health

Jordi Hermoso jordiup

🙌
Building The Future Of Digital Health
View GitHub Profile
@jordiup
jordiup / zod-postgres-connection.ts
Created August 29, 2024 14:45
Zod Postgres Connection Schema
import { z } from 'zod';
const connectionSchema = z.object({
user: z.string(),
password: z.string(),
host: z.string(),
database: z.string(),
port: z.number().int().positive().default(5432),
ssl: z.boolean().default(true),
pooling: z.boolean().default(true),
SELECT
EXTRACT(MONTH FROM s."shiftStart")::int AS month,
/* ---------- average hourly rate ---------- */
ROUND(AVG(
CASE
WHEN s."positionParentCategory" = 'Consultant' THEN
CASE
WHEN s."isDayRate" THEN s.cost / NULLIF(s.hours, 0)
WHEN s."isHourlyRate" THEN s.rate