pl4y-data-library
Version:
This library contains the dtos, enums, schemas, and other data objects needed in the pl4y ecosystem.
34 lines (27 loc) • 862 B
text/typescript
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Document, Types } from "mongoose";
import { StockStatus } from "../enums/stock-level-status.enum";
// Defines the interface for your document
export type StockLevelsDocument = StockLevels & Document;
()
export class StockLevels {
({
type: Types.ObjectId,
ref: "Product",
required: true,
unique: true,
})
productId: Types.ObjectId;
({
type: String,
enum: Object.values(StockStatus).filter((value) => typeof value === "string"),
default: StockStatus.IN_STOCK,
})
status: StockStatus;
()
backroomQuantity: number;
()
salesFloorQuantity: number;
}
// Generates the actual Mongoose Schema
export const StockLevelsSchema = SchemaFactory.createForClass(StockLevels);