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
text/typescript
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;
()
export class StockTransfer {
({
type: Types.ObjectId,
ref: "Product",
required: true,
unique: true,
})
productId: Types.ObjectId;
({
type: String,
enum: Object.values(StockLocation).filter((value) => typeof value === "string"),
})
from: StockLocation;
({
type: String,
enum: Object.values(StockLocation).filter((value) => typeof value === "string"),
})
to: StockLocation;
({ required: true })
quantity: number;
({ default: Date.now })
transferredAt: Date;
}
// Generates the actual Mongoose Schema
export const StockTransferLogSchema = SchemaFactory.createForClass(StockTransfer);