I have a method to do some typeorm actions on an entity.
async deactivateBarcode(barcode: string) {
let currentBarcode: Barcode = await this.barcodeRepository.findOne({
code: barcode,
});
currentBarcode.isActive = true;
return await this.barcodeRepository.save(currentBarcode);
}
this prints an error message for the line "currentBarcode.isActive'
TypeError: Cannot set property 'isActive' of undefined
but when I hard code the barcode value in to the { code: 'hardcodebarcode'}, the line 'currentBarcode.isActive' has value and it works..
async deactivateBarcode(barcode: string) {
let currentBarcode: Barcode = await this.barcodeRepository.findOne({
code: '3sfsdfsderer',
});
currentBarcode.isActive = true;
return await this.barcodeRepository.save(currentBarcode);
}
My question, what is happening in this method which is causing this different behavior that 'when passed as parameter' or 'when hardcoded the same value'..