UNPKG

pl4y-data-library

Version:

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

34 lines (27 loc) 917 B
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 = StockTransferLog & Document; @Schema() export class StockTransferLog { @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"), default: StockLocation.BACKROOM, }) location: StockLocation; @Prop({ required: true }) quantity: number; @Prop({ default: Date.now }) transferredAt: Date; } // Generates the actual Mongoose Schema export const StockTransferLogSchema = SchemaFactory.createForClass(StockTransferLog);