const mongoose = require('mongoose'), Schema = mongoose.Schema, { SubType } = require('./subscription'); const schema = new Schema({ subType: { type: { type: String, enum: { values: Object.values(SubType), message: '{VALUE} for subscription \'type\' is not supported' } } }, periodStart: { type: Number, require: true }, periodEnd: { type: Number, require: true }, custId: { type: String }, // Stripe customer Id lookupKey: { type: String }, // The lookup key for the price used within the subscription in the billing period }); //TODO: create an index based on subId and periods for quick query later on module.exports = mongoose.model('Bill_Period', schema);