Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
Mongoose MongoDB TTL expiry

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
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!