import { Injectable } from '@nestjs/common';
import { Event } from './models/Event';
import { Client } from '../client';
import { UUID } from '../global/scalars/UUID';
import { Date } from '../global/scalars/Date';
import { Service } from '../global/service'

@Injectable()
export class EventService extends Service<Event> {
  constructor() {
    super();
    this.collection = 'event';
  }

  async create(client: Client, date: Date, organizer: UUID, name?: string): Promise<Event> {
    const neu = {
      name: name || null,
      date,
      _organizer: organizer,
    }

    return super.insert(client, neu);
  }
}