You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
759 B
JavaScript

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
module.exports.schema = new Schema({
code: {type: String, required: true, unique: true, index: true},
numAllowedUses: {type: Number, required: true, default: 1},
uses: [{type: Schema.Types.ObjectId, required: true, ref: 'Cart'}],
expires: {type: Number, required: true, default: 0},
flatDiscount: {type: Number, required: true, default: 0},
percentDiscount: {type: Number, required: true, default:0},
socksFree: {type: Number, required: true, default: 0},
perSockDiscount: {type: Number, required: false, default: 0},
freeShipping: {type: Boolean, required: true, default: false}
}, {
usePushEach: true
});
module.exports.model = mongoose.model('Coupon', module.exports.schema);