Create a conditional TTL in mongo

后端 未结 4 1829
你的背包
你的背包 2021-02-06 03:05

There is a particular task I want to accomplish, but I am not finding any particular way to do that. Let\'s say I have an app that is used to send mails. I keep a record of thes

4条回答
  •  佛祖请我去吃肉
    2021-02-06 03:42

    const mongoose = require("mongoose");
    const Schema = mongoose.Schema;
    
    let PassWordReSate = new Schema(
      {
        hex: String,
        email: String,
      },
      {
        collection: "PassWordReSate",
        timestamps: true,
      }
    );
    PassWordReSate.path("createdAt").index({ expires: 6 });
    module.exports = mongoose.model("PassWordReSate", PassWordReSate);
    

提交回复
热议问题