25 lines
957 B
TypeScript
25 lines
957 B
TypeScript
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>>;
|