Start Umbau zu postgres
This commit is contained in:
12
bizmatch-server/src/drizzle/businesses_json.model.ts
Normal file
12
bizmatch-server/src/drizzle/businesses_json.model.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { jsonb, varchar } from 'drizzle-orm/pg-core';
|
||||
import { pgTable, text, primaryKey } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const businesses_json = pgTable('businesses_json', {
|
||||
id: varchar('id', { length: 255 }).primaryKey(),
|
||||
data: jsonb('data'),
|
||||
});
|
||||
|
||||
export type BusinessesJson = {
|
||||
id: string;
|
||||
data: Record<string, any>;
|
||||
};
|
||||
27
bizmatch-server/src/drizzle/drizzle.module.ts
Normal file
27
bizmatch-server/src/drizzle/drizzle.module.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
import pkg from 'pg';
|
||||
const { Pool } = pkg;
|
||||
import * as schema from './businesses_json.model.js';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { jsonb, varchar } from 'drizzle-orm/pg-core';
|
||||
import { PG_CONNECTION } from './schema.js';
|
||||
@Module({
|
||||
providers: [
|
||||
{
|
||||
provide: PG_CONNECTION,
|
||||
inject: [ConfigService],
|
||||
useFactory: async (configService: ConfigService) => {
|
||||
const connectionString = configService.get<string>('DATABASE_URL');
|
||||
const pool = new Pool({
|
||||
connectionString,
|
||||
// ssl: true,
|
||||
});
|
||||
|
||||
return drizzle(pool, { schema });
|
||||
},
|
||||
},
|
||||
],
|
||||
exports: [PG_CONNECTION],
|
||||
})
|
||||
export class DrizzleModule {}
|
||||
15
bizmatch-server/src/drizzle/schema.ts
Normal file
15
bizmatch-server/src/drizzle/schema.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { integer, serial, text, pgTable } from 'drizzle-orm/pg-core';
|
||||
import { relations } from 'drizzle-orm';
|
||||
import { jsonb, varchar } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const PG_CONNECTION = 'PG_CONNECTION';
|
||||
|
||||
export const businesses_json = pgTable('businesses_json', {
|
||||
id: varchar('id', { length: 255 }).primaryKey(),
|
||||
data: jsonb('data'),
|
||||
});
|
||||
|
||||
export type BusinessesJson = {
|
||||
id: string;
|
||||
data: Record<string, any>;
|
||||
};
|
||||
Reference in New Issue
Block a user