import { Column, CreateDateColumn, PrimaryGeneratedColumn } from 'typeorm'

export class BaseEntity<T> {
	/**
	 * Id of the entity in UUID format
	 */
	@PrimaryGeneratedColumn('uuid')
	id: string

	/**
	 * Date at which the entity was created
	 */
	@CreateDateColumn()
	createdAt: Date

	/**
	 * Id of the tenant that owns the entity
	 */
	@Column({
		type: 'uuid',
		nullable: true,
	})
	tenantId?: string

	constructor(object: Partial<T>) {
		Object.assign(this, object)
	}
}
