Fixed upsert new DeviceInfo with null isAutoBackup property

This commit is contained in:
Alex Tran 2022-12-10 08:36:21 -06:00
parent f096910abc
commit 09103dc981
No known key found for this signature in database
GPG key ID: E4954BC787B85C8A
9 changed files with 9 additions and 27 deletions

View file

@ -18,12 +18,14 @@ export class DeviceInfoService {
const exists = await this.repository.findOne({ where: { userId, deviceId } });
if (!exists) {
if (!entity.isAutoBackup) {
entity.isAutoBackup = false;
}
return await this.repository.save(entity);
}
exists.isAutoBackup = entity.isAutoBackup ?? exists.isAutoBackup;
exists.deviceType = entity.deviceType ?? exists.deviceType;
return await this.repository.save(exists);
}
}