UNPKG

pl4y-data-library

Version:

This library contains the dtos, enums, schemas, and other data objects needed in the pl4y ecosystem.

39 lines (31 loc) 1.02 kB
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose"; import { Document, Types } from "mongoose"; import { StockLocation } from "../enums/stock-location.enum"; // Defines the interface for your document export type StockTransferLogDocument = StockTransfer & Document; @Schema() export class StockTransfer { @Prop({ type: Types.ObjectId, ref: "Product", required: true, unique: true, }) productId: Types.ObjectId; @Prop({ type: String, enum: Object.values(StockLocation).filter((value) => typeof value === "string"), }) from: StockLocation; @Prop({ type: String, enum: Object.values(StockLocation).filter((value) => typeof value === "string"), }) to: StockLocation; @Prop({ required: true }) quantity: number; @Prop({ default: Date.now }) transferredAt: Date; } // Generates the actual Mongoose Schema export const StockTransferLogSchema = SchemaFactory.createForClass(StockTransfer);