0

Book collection contains a Date type field. In $match aggregation pipeline I used:

Product.aggregate([{ 
              $match: {"published_at": 
              { $regex: '.*' + req.query.terms + '.*', $options:'i'} 
             }
           }])

Product collection looks like following.But it do not work properly. If published_at field would a string above query works as my expectation. Is it possible to search Product with published_at Date field like LIKE ?

{
 "_id" : ObjectId("5a2934934410bf8b0e547989"),
 "published_at" : ISODate("2017-12-21T07:15:16.528Z"),
 "name" : "Rabindranath : Jethay Joto Alo",
 "author" : [ 
        ObjectId("5a27c5754b0efc477f37a131")
    ],
 "publisher" : ObjectId("5a27e7b68021772210b125d4"),
}
Shamim Hossain
  • 650
  • 8
  • 21

0 Answers0