customer.entity.ts 993 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { DeepPartial } from 'shared/shared-types';
  2. import { HasCustomFields } from 'shared/shared-types';
  3. import { Column, Entity, JoinColumn, OneToMany, OneToOne } from 'typeorm';
  4. import { Address } from '../address/address.entity';
  5. import { VendureEntity } from '../base/base.entity';
  6. import { CustomCustomerFields } from '../custom-entity-fields';
  7. import { User } from '../user/user.entity';
  8. @Entity()
  9. export class Customer extends VendureEntity implements HasCustomFields {
  10. constructor(input?: DeepPartial<Customer>) {
  11. super(input);
  12. }
  13. @Column() firstName: string;
  14. @Column() lastName: string;
  15. @Column({ nullable: true })
  16. phoneNumber: string;
  17. @Column({ unique: true })
  18. emailAddress: string;
  19. @OneToMany(type => Address, address => address.customer)
  20. addresses: Address[];
  21. @OneToOne(type => User, { eager: true })
  22. @JoinColumn()
  23. user?: User;
  24. @Column(type => CustomCustomerFields)
  25. customFields: CustomCustomerFields;
  26. }