myDataBase.aggregate(pipeline) .toArray() .then(respond => { return respond == null ? res.json([]) : res.json(respond); })