This commit is contained in:
mahyargdz
2025-09-14 15:15:03 +03:30
commit be82059172
534 changed files with 51310 additions and 0 deletions
@@ -0,0 +1,39 @@
import mongoose, { Schema, model } from "mongoose";
import { IShipmentCost, IShipmentProviders } from "./Abstraction/IShipmentProviders";
import { DeliveryType } from "../../../common/enums/shipment.enum";
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
const AutoIncrement = require("mongoose-sequence")(mongoose);
const ShipmentCostSchema = new Schema<IShipmentCost>(
{
weightRange: {
min: { type: Number, required: true },
max: { type: Number, required: true },
},
cost_first: { type: Number, required: true },
cost_rest: { type: Number, required: true },
},
{ _id: false },
);
const ShipmentSchema = new Schema<IShipmentProviders>(
{
_id: Number,
name: { type: String, unique: true, required: true },
description: String,
// availableShippingDays: { type: [String], require: true },
costs: [ShipmentCostSchema],
deliveryType: { type: String, enum: DeliveryType, required: true },
deliveryTime: { type: Number, required: true },
deleted: { type: Boolean, default: false },
},
{ timestamps: true, toJSON: { versionKey: false }, _id: false, id: false },
);
ShipmentSchema.plugin(AutoIncrement, { id: "shipment_id", inc_field: "_id", start_seq: 100 });
const ShipmentModel = model<IShipmentProviders>("Shipment", ShipmentSchema);
export { ShipmentModel, IShipmentProviders };