Answers for "get docs with date intervals mongoose"

0

get docs with date intervals mongoose

db.posts.find({ //query today up to tonight
    created_on: {
        $gte: new Date(2012, 7, 14), 
        $lt: new Date(2012, 7, 15)
    }
})
Posted by: Guest on May-13-2021
0

get docs with date intervals mongoose

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 May-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language