system-information.ts 743 B

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