- 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.
34 lines
950 B
JavaScript
34 lines
950 B
JavaScript
import mongoose from 'mongoose';
|
|
const { Schema } = mongoose;
|
|
|
|
// Define the main filamentStock schema
|
|
const filamentStockSchema = new Schema(
|
|
{
|
|
state: {
|
|
type: { type: String, required: true },
|
|
percent: { type: String, required: true },
|
|
},
|
|
startingWeight: {
|
|
net: { type: Number, required: true },
|
|
gross: { type: Number, required: true },
|
|
},
|
|
currentWeight: {
|
|
net: { type: Number, required: true },
|
|
gross: { type: Number, required: true },
|
|
},
|
|
filament: { type: mongoose.Schema.Types.ObjectId, ref: 'filament' },
|
|
},
|
|
{ timestamps: true }
|
|
);
|
|
|
|
// Add virtual id getter
|
|
filamentStockSchema.virtual('id').get(function () {
|
|
return this._id.toHexString();
|
|
});
|
|
|
|
// Configure JSON serialization to include virtuals
|
|
filamentStockSchema.set('toJSON', { virtuals: true });
|
|
|
|
// Create and export the model
|
|
export const filamentStockModel = mongoose.model('filamentStock', filamentStockSchema);
|