import { Document, Schema, Types } from 'mongoose'; export interface WaybillSchema extends Document { operation: 'in' | 'out'; records: [{ productId: string; price: number; quantity: number; }]; contractorId: string; status: 'waiting' | 'executed' | 'cancelled'; } const recordSchema = new Schema({ productId: { type: Types.ObjectId, required: true, }, price: { type: Number, required: true, }, quantity: { type: Number, min: 1, }, }); export const waybillSchema = new Schema({ operation: { type: String, required: true, }, contractorId: { type: Types.ObjectId, required: true, }, records: [recordSchema], status: { type: String, default: 'waiting', }, }, { timestamps: true });