Files
bizmatch-project/bizmatch-server/src/event/event.service.ts

24 lines
886 B
TypeScript

import { Inject, Injectable } from '@nestjs/common';
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { ListingEvent } from 'src/models/db.model';
import { Logger } from 'winston';
import * as schema from '../drizzle/schema';
import { listing_events_json, PG_CONNECTION } from '../drizzle/schema';
@Injectable()
export class EventService {
constructor(
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
@Inject(PG_CONNECTION) private conn: NodePgDatabase<typeof schema>,
) {}
async createEvent(event: ListingEvent) {
// Speichere das Event in der Datenbank
event.eventTimestamp = new Date();
const { id, email, ...rest } = event;
const convertedEvent = { email, data: rest };
await this.conn.insert(listing_events_json).values(convertedEvent).execute();
}
}