I'm building a node.js app using MongoDB (mongoose). I have the following schema, and I want any entry to expire deleted after 5m. However, currently the entries get deleted after around 2 min. I have looked at all the documentation and have tried several ways but it deletes before 2 minutes. Any other way to solve this? Thank you in advance
const postSchema = new Schema({
expireAt: {
type: Date,
default: Date.now,
expires: 300
},
title: String,
date: Date,
country: String,
salary: String,
image: String,
company: {
type: Schema.Types.ObjectId,
ref: 'Company'
},
application: [{
type: Schema.Types.ObjectId,
ref: 'Application'
}]
})
I tried:
postSchema.index( { "expireAt": 1 }, { expireAfterSeconds: 60*60*24*5 #Every 5 days} )