import * as mongoose from "mongoose";
import { model, AggregatePaginateModel } from "mongoose";
const aggregatePaginate = require("mongoose-aggregate-paginate-v2");
const Schema = mongoose.Schema;

const Discount = new Schema(
  {
    type: {
      type: String,
    },
    code: {
      type: String,
    },
    from_date: {
      type: String,
    },
    to_date: {
      type: String,
    },
    amount: {
      type: Number,
    },
    min_amount: {
      type: Number,
    },
    percentage: {
      type: Number,
    },
    is_active: {
      type: Boolean,
      default: true,
    },
  },
  {
    timestamps: {
      createdAt: "created_at",
      updatedAt: "updated_at",
    },
  }
);
mongoose.plugin(aggregatePaginate);

export default model<any, AggregatePaginateModel<any>>("Discount", Discount);
