import { EntitySchema } from '@mikro-orm/core';
import { BaseEntity } from '../../core/entities/base.entity';

export class TodoItem extends BaseEntity {
  title!: string;
  description?: string;
  completed: boolean = false;
  dueDate?: Date;
}

export const TodoItemSchema = new EntitySchema<TodoItem>({
  class: TodoItem,
  tableName: 'todo_items',
  properties: {
    id: { type: 'uuid', primary: true },
    tenantId: { type: 'string' },
    metadata: { type: 'json', nullable: true },
    createdAt: { type: 'date', defaultRaw: 'now()' },
    updatedAt: { type: 'date', defaultRaw: 'now()' },

    title: { type: 'string' },
    description: { type: 'text', nullable: true },
    completed: { type: 'boolean', default: false },
    dueDate: { type: 'date', nullable: true },
  },
});
