profile.entity.ts 1022 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { DeepPartial } from '@vendure/common/lib/shared-types';
  2. import { User, VendureEntity } from '@vendure/core';
  3. import { Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne } from 'typeorm';
  4. import { ProfileAsset } from './profile-asset.entity';
  5. @Entity()
  6. export class Profile extends VendureEntity {
  7. constructor(input?: DeepPartial<Profile>) {
  8. super(input);
  9. }
  10. /**
  11. * The reference to a user
  12. */
  13. @ManyToOne(() => User, user => (user as any).profileId, { onDelete: 'CASCADE' })
  14. user: User;
  15. /**
  16. * Profile display name
  17. */
  18. @Column()
  19. name: string;
  20. /**
  21. * The profile picture
  22. */
  23. @OneToOne(() => ProfileAsset, profileAsset => profileAsset.profile, {
  24. onDelete: 'SET NULL',
  25. nullable: true,
  26. })
  27. @JoinColumn()
  28. featuredAsset: ProfileAsset;
  29. /**
  30. * Other assets
  31. */
  32. @OneToMany(() => ProfileAsset, profileAsset => profileAsset.profile, {
  33. onDelete: 'CASCADE',
  34. })
  35. assets: ProfileAsset[];
  36. }