Tom Butcher ce15d3dbfc Add inventory and management schemas for filament, part, and stock management
- Introduced new schemas for managing inventory, including filamentStock, partStock, stockAudit, stockEvent, and their respective models.
- Added management schemas for user, vendor, material, and various document types to enhance data structure and organization.
- Implemented necessary fields and relationships to support inventory tracking and management functionalities.
2025-08-18 01:06:38 +01:00

26 lines
762 B
JavaScript

import mongoose from 'mongoose';
const { Schema } = mongoose;
// Define the main partStock schema
const partStockSchema = new Schema(
{
name: { type: String, required: true },
fileName: { type: String, required: false },
part: { type: mongoose.Schema.Types.ObjectId, ref: 'part' },
startingQuantity: { type: Number, required: true },
currentQuantity: { type: Number, required: true },
},
{ timestamps: true }
);
// Add virtual id getter
partStockSchema.virtual('id').get(function () {
return this._id.toHexString();
});
// Configure JSON serialization to include virtuals
partStockSchema.set('toJSON', { virtuals: true });
// Create and export the model
export const partStockModel = mongoose.model('partStock', partStockSchema);