In postgres we use the below code when we need a time series data for a line chart
SELECT date_trunc('day', dd)::date
FROM generate_series
( '2004-04-01'::timestamp
, '2005-04-01'::timestamp
, '1 day'::interval) dd
LEFT JOIN school_attendence on dd = school_attendence.attendence_date
Is there a similar function in mongodb or mongoose library that will do the job for me?
You can use tool mgeneratejs :
//install mongo and down mongoinport
//install tool
$ npm install -g mgeneratejs
//generate 10000000 documents for mongodb
$ mgeneratejs '{"name": "$name", "age": "$age", "emails": {"$array": {"of": "$email", "number": 3}}}' -n 10000000 | mongoimport --uri mongodb://localhost:27017/test --collection user --mode insert