mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 13:39:41 +02:00
20 lines
674 B
TypeScript
20 lines
674 B
TypeScript
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
import postgres from 'postgres';
|
|
import * as schema from './schema';
|
|
|
|
// Re-export schema and types
|
|
export * from './schema';
|
|
export { sql, eq, and, or, desc, asc, isNull, isNotNull, inArray } from 'drizzle-orm';
|
|
|
|
// Export schema for use in drizzle initialization
|
|
export { schema };
|
|
|
|
// Type for the database instance with schema
|
|
export type Database = PostgresJsDatabase<typeof schema>;
|
|
|
|
// Helper to create a new database connection
|
|
export function createDb(url: string): Database {
|
|
const client = postgres(url);
|
|
return drizzle(client, { schema });
|
|
}
|