Creating a schedule to delete expired tokens

Hi, I’m new to Mongo and I’m trying to create a schedule to delete expired tokens.
Since I’m new I don’t know much I tried to get the collection but then I don’t know how to check if the value expired is inferior than the present time.
so basically the logic I want to implement is
let tokens = mongodb.db(“db”).collection(“tokens”);
let now = new Date();
tokens.foreach(x){
if( x.expires lt now)
x.erase
};