MongoDB和NodeJS的最大调用堆栈大小超过

时间:2018-12-18 22:16:15

标签: node.js mongodb socket.io aggregate

我将NodeJS与MongoClient(mongodb)结合使用。我正在尝试通过调用集合中的聚合函数从MongoDB数据库中获取一些数据。运行它时,出现以下错误:

RangeError: Maximum call stack size exceeded


    at Object.hasOwnProperty (<anonymous>)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:41)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:59)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:59)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:59)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:59)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:59)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:59)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:59)
    at hasBinary (C:\Users\MyName\Documents\charts_generator\node_modules\has-binary2\index.js:58:59)

这是我的代码:

const col = client.db(dbName).collection("statistiquesQuotidiennes");
col.aggregate(
    [
        {$match: { spectacle: artist }},
        {
            $group: {
            _id: { month: { $month: "$jourVente" }, day: { $dayOfMonth: "$jourVente" }, year: { $year: "$jourVente" } },
            totalTickets: {$sum:"$billets"}
            }
        }
    ],
    function(err,docs)
    {
        if (err)
        {
        }
        else
        {
            socket.emit("changerArtiste",docs);
        }

    }
)

0 个答案:

没有答案