import { randomUUID } from 'node:crypto' import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core' import type { UUID } from '@/application/types' import type { User } from '@/entities/user' import { BaseEntity } from '@/application/base/baseEntity' export class BasePasswordResetToken extends BaseEntity { @PrimaryKey() id = randomUUID() @ManyToOne({ deleteRule: 'cascade' }) user!: User @Property({ unique: true }) token!: string @Property() createdAt = new Date() setId(id: UUID) { this.id = id return this } getId() { return this.id } setUser(user: User) { this.user = user return this } getUser() { return this.user } setToken(token: string) { this.token = token return this } getToken() { return this.token } setCreatedAt(createdAt: Date) { this.createdAt = createdAt return this } getCreatedAt() { return this.createdAt } }