I am trying to make a full stack app where the MongoDB BSON document expires after a certain period of time. As you can see below, I put the expiry time at 4 minutes. However, the document gets deleted by 2:20 minutes. I have tried testing the expiry time at 2m, 3m. They are all expiring at within a span of 2:10-2:45 minutes. I am not sure why this is happening. What should I do to fix this?
const mongoose = require('mongoose')
const userSchema = new mongoose.Schema({
note: {
type: String,
required: true,
},
completed:{
type: Boolean
},
createdAt: { type: Date, expires: '4m', default: Date.now }
})
const User = mongoose.model('user', userSchema)
module.exports = User