2
0

system-information.ts 751 B

12345678910111213141516171819202122
  1. import { EntityRepository, Repository } from 'typeorm';
  2. import { SystemInformation } from '~/entities/system-information';
  3. @EntityRepository(SystemInformation)
  4. export class SystemInformationRepository extends Repository<SystemInformation> {
  5. async createOrUpdateUniqueRecordWithVersion(
  6. systemInfo: SystemInformation | undefined,
  7. proxyVersion: string,
  8. ): Promise<void> {
  9. // update the version if it exists
  10. if (systemInfo != null) {
  11. systemInfo.setVersion(proxyVersion);
  12. await this.save(systemInfo);
  13. return;
  14. }
  15. // create new system information object if it didn't exist
  16. const newSystemInfo = new SystemInformation();
  17. newSystemInfo.setVersion(proxyVersion);
  18. await this.save(newSystemInfo);
  19. }
  20. }