Answers for "Find posts in MongoDB within a single day"

0

Find posts in MongoDB within a single day

const moment = require('moment')

const today = moment().startOf('day')

MyModel.find({
  createdAt: {
    $gte: today.toDate(),
    $lte: moment(today).endOf('day').toDate()
  }
})
Posted by: Guest on July-18-2021

Browse Popular Code Answers by Language