This commit is contained in:
2025-11-16 12:07:39 +03:30
parent d605303e52
commit b3c44d734c
10 changed files with 88 additions and 25 deletions
@@ -1,6 +1,5 @@
import { Entity, ManyToOne, Opt, Property } from '@mikro-orm/core';
import { User } from './user.entity';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from '../../../modules/restaurants/entities/restaurant.entity';
@@ -9,8 +8,8 @@ export class RefreshToken extends BaseEntity {
@Property({ type: 'varchar', length: 255 })
token!: string;
@ManyToOne(() => User, { deleteRule: 'cascade' })
user!: User;
@Property()
ownerId!: string;
@ManyToOne(() => Restaurant, { deleteRule: 'cascade' })
restaurant!: Restaurant;
+1 -5
View File
@@ -1,5 +1,4 @@
import { Entity, Property, OneToMany, Collection, OneToOne } from '@mikro-orm/core';
import { RefreshToken } from './refresh-token.entity';
import { Entity, Property, OneToOne } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
@@ -8,9 +7,6 @@ export class User extends BaseEntity {
@OneToOne(() => Restaurant, { owner: true })
restaurant!: Restaurant;
@OneToMany(() => RefreshToken, token => token.user)
refreshTokens = new Collection<RefreshToken>(this);
@Property()
firstName!: string;
+2 -1
View File
@@ -5,11 +5,12 @@ import { MikroOrmModule } from '@mikro-orm/nestjs';
import { User } from './entities/user.entity';
import { JwtModule } from '@nestjs/jwt';
import { UserRepository } from './repositories/user.repository';
import { RefreshToken } from './entities/refresh-token.entity';
@Module({
providers: [UserService, UserRepository],
controllers: [AdminUserController],
imports: [MikroOrmModule.forFeature([User]), JwtModule],
imports: [MikroOrmModule.forFeature([User, RefreshToken]), JwtModule],
exports: [UserService, UserRepository],
})
export class UserModule {}