product-review.entity.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* eslint-disable @typescript-eslint/no-unused-vars */
  2. import { Customer, DeepPartial, Product, ProductVariant, VendureEntity } from '@vendure/core';
  3. import { Column, Entity, ManyToOne } from 'typeorm';
  4. import { ReviewState } from '../types';
  5. @Entity()
  6. export class ProductReview extends VendureEntity {
  7. constructor(input?: DeepPartial<ProductReview>) {
  8. super(input);
  9. }
  10. @ManyToOne(type => Product)
  11. product: Product;
  12. @ManyToOne(type => ProductVariant)
  13. productVariant: ProductVariant | null;
  14. @Column()
  15. summary: string;
  16. @Column('text')
  17. body: string;
  18. @Column()
  19. rating: number;
  20. @ManyToOne(type => Customer)
  21. author: Customer;
  22. @Column()
  23. authorName: string;
  24. @Column({ nullable: true })
  25. authorLocation: string;
  26. @Column({ default: 0 })
  27. upvotes: number;
  28. @Column({ default: 0 })
  29. downvotes: number;
  30. @Column('varchar')
  31. state: ReviewState;
  32. @Column('text', { nullable: true, default: null })
  33. response: string;
  34. @Column({ nullable: true, default: null })
  35. responseCreatedAt: Date;
  36. }