diff options
Diffstat (limited to 'src/models/waybill')
-rw-r--r-- | src/models/waybill/waybill.model.ts | 4 | ||||
-rw-r--r-- | src/models/waybill/waybill.schema.ts | 33 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/models/waybill/waybill.model.ts b/src/models/waybill/waybill.model.ts new file mode 100644 index 0000000..3769eec --- /dev/null +++ b/src/models/waybill/waybill.model.ts @@ -0,0 +1,4 @@ +import { Model, model } from 'mongoose'; +import { WaybillSchema, waybillSchema } from './waybill.schema'; + +export default model<WaybillSchema, Model<WaybillSchema>>('Waybill', waybillSchema); 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 }); + |