Mongoose“过期”删除文档太快

问题描述

我正在尝试通过设置 expires 创建自动过期的 Mongoose 文档。

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

我希望它在 20 分钟后终止,但它在大约 1 - 2 分钟后继续终止。

我也试过 { expires: '20m' },它也会在大约 1 - 2 分钟后删除文档。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)