I\'m quite new to web development and I want to learn new things. I have a mongoose schema (I won\'t post it because it\'s in my own language, you won\'t understand, so I will e
What you are asking basically can't be done just like that you have 2 ways about going this route.
pre('find')
that will check if 4 weeks have passed if so then change the deactivated to true
you can learn more about hooks on hereSomething similar to this example - this example was taken from here
Schema.pre('find', function() {
if (!this.getQuery().userId) {
this.error(new Error('Not allowed to query without setting userId'));
}
});
deactivated
to true
This is a good cron package cron
EDIT: The cron job can be any period, every 10 minutes, 1 hour, 2, 100, etc...
Good luck