showing results for - "how to filter data from mongodb date in reactjs"
Niko
26 Aug 2019
1ar moment = require ('moment')
2
3 function previous_year_artist(req, res, next) {
4        var dateTimeTofilter = moment().subtract(1, 'year');
5        var filter = {
6            "date_added": {
7                $gte: new Date(dateTimeTofilter._d)
8            }
9        };
10        db.collection.find(
11            filter
12        ).toArray(function(err, result) {
13            if (err) return next(err);
14            res.send(result);
15        });
16
17    }