fix aggregate(xx).cursor({}).exec().toArray() is not function

This commit is contained in:
jayzou 2019-01-16 21:47:34 +08:00
parent 3ed74da12c
commit 2ac288a8d4

View File

@ -35,10 +35,11 @@ class statisMockModel extends baseModel {
return this.model.countDocuments({});
}
getDayCount(timeInterval) {
async getDayCount(timeInterval) {
let end = timeInterval[1];
let start = timeInterval[0];
return this.model.aggregate([
let data = [];
const cursor = this.model.aggregate([
{
$match: {
date: { $gt: start, $lte: end }
@ -53,8 +54,11 @@ class statisMockModel extends baseModel {
{
$sort: { _id: 1 }
}
]).cursor({}).exec().toArray();
}
]).cursor({}).exec();
await cursor.eachAsync(doc => data.push(doc));
return data;
}
list() {
return this.model.find({}).select('date').exec();