19 lines
737 B
TypeScript
19 lines
737 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 * as schema from '../drizzle/schema';
|
|
import { listingEvents, 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();
|
|
await this.conn.insert(listingEvents).values(event).execute();
|
|
}
|
|
}
|