lifetracker/packages/db/index.ts
2025-01-31 18:09:27 -08:00

25 lines
957 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Pool, QueryResult } from "pg";
import { ExtractTablesWithRelations } from "drizzle-orm";
import { PgTransaction } from "drizzle-orm/pg-core";
import * as schema from "./schema";
// Export the db instance from your drizzle setup (make sure your drizzle file is updated for Postgres)
export { db } from "./drizzle";
export * as schema from "./schema";
// If you need to export Postgres errors, you can export them from the pg package.
// (Optional remove if not needed)
export { DatabaseError } from "pg";
export const ErrorCodes = {
UNIQUE_VIOLATION: "23505",
};
/**
* This type alias is provided to avoid leaking pg types outside of this package.
*
* Note:
* - The first generic parameter is set to "async" because most PostgreSQL drivers (like pg) are asynchronous.
* - The second generic parameter uses pg's QueryResult type.
*/
export type LifetrackerDBTransaction = PgTransaction<any, ExtractTablesWithRelations<typeof schema>>;