Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Prop, raw, Schema, SchemaFactory} from '@nestjs/mongoose';
- import { Document } from 'mongoose';
- import * as Mongoose from "mongoose";
- import {orderLifetime, OrderStatusType} from "./order.constants";
- import {Product} from "../product/product.schema";
- export type OrderDocument = Order & Document;
- @Schema()
- class Products {
- @Prop({type: Mongoose.Schema.Types.ObjectId, ref: 'Product'})
- productId: Product
- @Prop()
- productName: String
- @Prop()
- sumKeys: Number
- @Prop([String])
- keys: string[]
- }
- @Schema()
- class Info {
- @Prop({default: new Date()})
- createdAt: Date
- @Prop({default: new Date().setTime(new Date().getTime() + orderLifetime) })
- cancelAt: Date
- @Prop()
- userIp: String
- }
- @Schema()
- export class Order {
- @Prop({type: [Products]})
- products: [Products];
- @Prop()
- price: number
- @Prop()
- status: OrderStatusType;
- @Prop({type: [Info]})
- info: [Info];
- }
- export const OrderSchema = SchemaFactory.createForClass(Order);
Advertisement
Add Comment
Please, Sign In to add comment