Node.js Mongoose.save()--TypeError:\u此[i].emit不是函数

Node.js Mongoose.save()--TypeError:\u此[i].emit不是函数,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,尝试保存文档时,会引发此错误: /Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/lib/utils.js:98 process.nextTick(function() { throw err; }); ^ TypeError: _this[i].emit is not a function at EventE

尝试保存文档时,会引发此错误:

/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/lib/utils.js:98
process.nextTick(function() { throw err; });
                              ^

TypeError: _this[i].emit is not a function
at EventEmitter.notify (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/lib/types/documentarray.js:238:18)
at emitOne (events.js:82:20)
at EventEmitter.emit (events.js:169:7)
at Document.(anonymous function) [as emit] (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/lib/document.js:93:44)
at EventEmitter.<anonymous> (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/lib/schema/embedded.js:31:15)
at emitTwo (events.js:92:20)
at EventEmitter.emit (events.js:172:7)
at model.Document.(anonymous function) [as emit] (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/lib/document.js:93:44)
at /Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/lib/model.js:227:11
at /Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/lib/model.js:135:7
at /Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/lib/collection.js:504:5
at /Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/lib/collection.js:666:5
at handleCallback (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/lib/utils.js:96:12)
at /Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js:473:9
at handleCallback (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/lib/utils.js:96:12)
at resultHandler (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js:420:5)
at commandCallback (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:1246:9)
at Callbacks.emit (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:119:3)
at null.messageHandler (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:397:23)
at Socket.<anonymous> (/Users/home/Documents/web/thp/modules/thp_db/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:302:22)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at TCP.onread (net.js:536:20)
奇怪的是,这昨晚运行得很好,除非我梦游并登录,否则一切都没有改变

db
变量是模型的集合


任何帮助都将不胜感激。

结果表明,根据填写提交表单的输入,会引发错误。目前还没有时间确定具体是哪一个,但我会在这里更新


更新:my
league
var由从传入表单数据解析的JSON对象填充。其中一个属性被轻率地称为
.on
,这是在愚弄标准事件侦听符号
.on
。愚蠢的错误!始终如此。

您是如何定义db.League的?
var db = req.app.locals.db;
var league = new db.League();

// league is populated here

// ================
// GIVE LEAGUE _id (auto increment)
// ================
db.Counter.findByIdAndUpdate('League',
                             { $inc: { n: 1 } },
                             { new: true },
    function(err, counter){
        if(err) return log.error('League _id set error', err);

        league._id = counter.n;

        // ================
        // INTO DB: CODE RUNS TO HERE
        // ================

        league.save(function(err, new_league) {

            // DOES NOT REACH HERE!

            if (err) {
                log.error('league DB entry error:', err);
                return res.status(200).end('Error creating league');
            }

            console.log('SAVED LEAGUE', util.inspect(new_league, false, null));

            res.status(200).end('Thank you');
        });
    }
);