How can I set the TTL date on document creation in Mongoose?
问题 I am trying to make a promoCode schema in Mongoose. On creation, I need to be able to set the promo code's expiration date. Promo codes do not necessarily have the same TTL . I looked at this question, but my documents still aren't expiring. This is my promoCode.js file: var mongoose = require("mongoose"); var promoCodeSchema = mongoose.Schema({ expirationDate: Date, createdAt: { type: Date, expireAfterSeconds: Number, default: Date.now } }) module.exports = mongoose.model("Promo",