Guest User

Untitled

a guest
Jun 7th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import {Prop, raw, Schema, SchemaFactory} from '@nestjs/mongoose';
  2. import { Document } from 'mongoose';
  3. import * as Mongoose from "mongoose";
  4. import {orderLifetime, OrderStatusType} from "./order.constants";
  5. import {Product} from "../product/product.schema";
  6.  
  7. export type OrderDocument = Order & Document;
  8.  
  9. @Schema()
  10. class Products {
  11. @Prop({type: Mongoose.Schema.Types.ObjectId, ref: 'Product'})
  12. productId: Product
  13.  
  14. @Prop()
  15. productName: String
  16.  
  17. @Prop()
  18. sumKeys: Number
  19.  
  20. @Prop([String])
  21. keys: string[]
  22. }
  23.  
  24. @Schema()
  25. class Info {
  26. @Prop({default: new Date()})
  27. createdAt: Date
  28.  
  29. @Prop({default: new Date().setTime(new Date().getTime() + orderLifetime) })
  30. cancelAt: Date
  31.  
  32. @Prop()
  33. userIp: String
  34. }
  35.  
  36.  
  37. @Schema()
  38. export class Order {
  39. @Prop({type: [Products]})
  40. products: [Products];
  41.  
  42. @Prop()
  43. price: number
  44.  
  45. @Prop()
  46. status: OrderStatusType;
  47.  
  48. @Prop({type: [Info]})
  49. info: [Info];
  50. }
  51.  
  52.  
  53. export const OrderSchema = SchemaFactory.createForClass(Order);
Advertisement
Add Comment
Please, Sign In to add comment