import {
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from "typeorm";

/**
 * Abstract entity containing basic fields that all entities have in common
 */
export abstract class AbstractEntity {
  @PrimaryGeneratedColumn("uuid")
  id?: string;

  @CreateDateColumn({name: "create_date"})
  createDate?: Date;

  @UpdateDateColumn({name: "update_date"})
  updateDate?: Date;

    /**
   * Checks whether entity has a valid ID
   * @todo check for valid UUID...
   */
  hasValidId() : boolean {
    return this.id !== undefined && this.id.length > 0;
  }
}
