Skip to content

Instantly share code, notes, and snippets.

@DulalSandip
Created April 13, 2021 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DulalSandip/08d4c8fd251102eae1a36bfd79e076a3 to your computer and use it in GitHub Desktop.
Save DulalSandip/08d4c8fd251102eae1a36bfd79e076a3 to your computer and use it in GitHub Desktop.
Coupon code models database
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const moment = require("moment");
// creating objectSchema
const couponCodeSchema = new Schema({
couponCodeName: {
type: String,
min: 5,
max: 15,
trim: true,
required: true,
},
productId: {
type: mongoose.Schema.Types.ObjectId,
ref: "product",
required: true,
},
discount: {
type: String,
},
discountStatus: {
type: Boolean,
required: true,
},
originalPrice: {
type: Number,
},
finalPrice: {
type: Number,
},
createdAt: {
type: String,
default: moment().format("DD/MM/YYYY") + ";" + moment().format("hh:mm:ss"),
},
updatedAt: {
type: String,
default: moment().format("DD/MM/YYYY") + ";" + moment().format("hh:mm:ss"),
},
expirationTime: {
type: String,
required: true,
},
});
const CouponCodeDiscount = mongoose.model(
"couponcode-discount-product",
couponCodeSchema
);
module.exports = CouponCodeDiscount;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment