Files
dkala-api/src/modules/auth/entities/refresh-token.entity.ts
T
2026-02-08 08:50:08 +03:30

30 lines
682 B
TypeScript

import { Entity, Enum, Index, Property } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
export enum RefreshTokenType {
USER = 'user',
ADMIN = 'admin',
}
@Entity({ tableName: 'refreshtokens' })
@Index({ properties: ['ownerId', 'restId', 'type'] })
@Index({ properties: ['hashedToken'] })
@Index({ properties: ['expiresAt'] })
export class RefreshToken extends BaseEntity {
@Property({ type: 'varchar', length: 255 })
hashedToken!: string;
@Property()
ownerId!: string;
@Property()
restId!: string;
@Enum(() => RefreshTokenType)
type!: RefreshTokenType;
@Property({ type: 'timestamptz' })
expiresAt!: Date;
}