const pictureEntity = updateUserDto?.picture
? await this.filesService.find(updateUserDto.picture)
: null;
if (pictureEntity) {
const url = await this.filesService.getFileUrl(pictureEntity);
}
Is the method used to assign the value to pictureEntity correct? In essence, if the property 'picture' is not defined, I'm avoiding using the find service in filesService as TypeORM may return a random value if 'picture' is null or undefined.
Initially, I attempted:
if (updateUserDto?.picture) {
const pictureEntity = await this.filesService.find(updateUserDto.picture);
}
However, TypeScript flagged an error since I was declaring a variable within an If statement.