Sunday, 8 December 2019

How to remove unverified user with Mongoose and TTL

Hello all!I would like to remove users that have not verified their accounts during a certain period of time. An user can have a google account (through Google´s API) or register locally. I only care about the locals ones.I have tried to do this with TTL without success, here is my User schema. Any idea what is wrong? So far I have not managed to remove them.Thank you in advance.const userSchema = mongoose.Schema({ local: { type: { email: { type: String, unique: true, required: true }, name: { type: String, required: true }, password: { type: String, required: true }, resetPasswordToken: String, resetPasswordExpires: Date, verificationToken: String, verificationExpires: Date, registrationConfirmed: Boolean }, required: false }, google: { id: String, name: String, email: String }, accountType: String }); userSchema.index( { 'local.verificationExpires': 1 }, { expireAfterSeconds: 0, partialFilterExpression: { 'local.registrationConfirmed': false } } ); module.exports = mongoose.model('User', userSchema);

Submitted December 08, 2019 at 05:31PM by dejavits

No comments:

Post a Comment