Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
654 views
in Technique[技术] by (71.8m points)

node.js - Mongoose "expires" deletes document too quick

I'm trying to create auto-expiring Mongoose document by setting expires.

const mySchema = new mongoose.Schema({
   title: {
      type: String,
      required: true
   },
   content: {
      type: String,
      required: true
   },
   expireAt: {
      type: Date,
      default: Date.now,
      index: { expires: 1200 } // Delete after 20 minutes.
   }
}, { collection: 'mycollection', timestamps: true });

I want it to terminate after 20 minutes but it keeps on terminating after about 1 - 2 minutes.

I've tried { expires: '20m' } as well which also deletes document after about 1 - 2 minutes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...