I have this entity:
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
ObjectID,
ObjectIdColumn,
} from 'typeorm';
import { Transform, Type } from 'class-transformer';
import { User } from './user.entity';
import { Prop } from '@nestjs/mongoose';
import mongoose from 'mongoose';
@Entity({ name: 'forgotpassword' })
export class ForgotPassword {
@ObjectIdColumn({ readonly: true })
@Transform(({ value }) => value.toString(), { toPlainOnly: true })
_id: ObjectID;
@Transform(({ value }) => value.toString(), { toPlainOnly: true })
@ManyToOne(() => User, {eager: true})
@JoinColumn({name: 'userId'})
userId: User;
@Column({ type: 'string' })
code: string;
@CreateDateColumn()
createdAt: Date;
}
and this method:
const forgotPass = await this.forgotPassRepo.findBy({
where: {
code: data.code,
},
});
when i try to get the userId i found that it not returned, although it existed in the document in the MongoDB, why these happen?
How can I resolve the problem? or tell me if there is a better solution