const pictureEntity = updateUserDto?.picture
? await this.filesService.find(updateUserDto.picture)
: null;
if (pictureEntity) {
const pictureEntity.url = await this.filesService.getFileUrl(pictureEntity);
}
Is this the correct way to assign the value to pictureEntity? Basically if property picture is not defined, I'm not supposed to use the service find in filesService because typeORM will return the first value that it finds if property picture is null or undefined.
I was doing this:
if (updateUserDto?.picture) {
const pictureEntity = await this.filesService.find(updateUserDto.picture);
}
but TS would complain because I'm declaring a variable inside an If.