summaryrefslogtreecommitdiff
path: root/src/models/waybill/waybill.schema.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/waybill/waybill.schema.ts')
-rw-r--r--src/models/waybill/waybill.schema.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/models/waybill/waybill.schema.ts b/src/models/waybill/waybill.schema.ts
new file mode 100644
index 0000000..ce14525
--- /dev/null
+++ b/src/models/waybill/waybill.schema.ts
@@ -0,0 +1,33 @@
+import { Document, Schema, Types } from 'mongoose';
+
+export interface WaybillSchema extends Document {
+ operation: 'in' | 'out';
+ productId: string;
+ quantity: number;
+ contractorId: string;
+ status: 'waiting' | 'executed' | 'cancelled';
+}
+
+export const waybillSchema = new Schema({
+ operation: {
+ type: String,
+ required: true,
+ },
+ contractorId: {
+ type: Types.ObjectId,
+ required: true,
+ },
+ productId: {
+ type: Types.ObjectId,
+ required: true,
+ },
+ quantity: {
+ type: Number,
+ min: 1,
+ },
+ status: {
+ type: String,
+ default: 'waiting',
+ },
+}, { timestamps: true });
+