#StackBounty: #node.js #typescript #mongodb #express #mongoose retrieve all whose `date` is within last 6 minutes

Bounty: 50

I have a Product collection stored in MongoDB. It has a attribute date :

const productSchema = new mongoose.Schema<ProductAttrs>({
    date: {
        type: Date, 
        required: true,
    }
    ...
})

I would like to retrieve all products whose date is within last 6 minutes comparing with current time. What is the efficient way to retrieve that in mongoose ?

I am using express.js + typescript + mongoose v5.11 in my project.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.