How can i change the Schema in MongoDB such that the record is deleted automatically from the database

Viewed 17

I want this record to be deleted after 3600 seconds of its creation.

const verifyModel = mongoose.Schema(
    {
        userId:{
            type:Schema.Types.ObjectId,
            required:true,
            ref:"User",
            unique:true,
        },
        token:{
            type:String,
            required:true,
        },
        createdAt:{
            type:Date,
            default:Date.now(),
        },
    }
);
0 Answers
Related