Created
April 13, 2021 08:39
-
-
Save DulalSandip/08d4c8fd251102eae1a36bfd79e076a3 to your computer and use it in GitHub Desktop.
Coupon code models database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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