base.entity.ts 703 B

12345678910111213141516171819202122232425
  1. import { CreateDateColumn, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
  2. import { DeepPartial, ID } from '../../../../shared/shared-types';
  3. import { primaryKeyType } from '../../config/vendure-config';
  4. const keyType = primaryKeyType();
  5. /**
  6. * This is the base class from which all entities inherit.
  7. */
  8. export abstract class VendureEntity {
  9. protected constructor(input?: DeepPartial<VendureEntity>) {
  10. if (input) {
  11. for (const [key, value] of Object.entries(input)) {
  12. this[key] = value;
  13. }
  14. }
  15. }
  16. @PrimaryGeneratedColumn(keyType) id: ID;
  17. @CreateDateColumn() createdAt: Date;
  18. @UpdateDateColumn() updatedAt: Date;
  19. }