我在Mongoose.js中收到以下错误。它不会一直发生,有时候也不会发生。
TypeError: this.isSelected is not a function
at model.Model.$__version (/app/node_modules/mongoose/lib/model.js:589:13)
at model.Model.$__delta (/app/node_modules/mongoose/lib/model.js:511:10)
at model.Model.$__handleSave (/app/node_modules/mongoose/lib/model.js:147:22)
at model.Model.$__save (/app/node_modules/mongoose/lib/model.js:185:9)
at model.Model.save (/app/node_modules/mongoose/lib/model.js:283:15)
at model._done (/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:101:24)
at _next (/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:64:28)
at fnWrapper (/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:186:8)
at model.Object.defineProperty.value.fn (/app/node_modules/mongoose/lib/schema.js:221:11)
at _next (/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:62:30)
at fnWrapper (/app/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:186:8)
at /app/node_modules/mongoose/lib/schema.js:196:17
at /app/node_modules/mongoose/node_modules/kareem/index.js:127:16
at wrapped (/app/node_modules/newrelic/lib/transaction/tracer/index.js:161:28)
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickDomainCallback [as _tickCallback] (node.js:390:13)
我认为产生该错误的相关代码如下:
exports.updateTheme = function(req, res) {
var theme = req.theme;
delete req.body.created;
delete req.body.modified;
delete req.body.user;
delete req.body._id;
theme.modified = new Date().getTime();
theme = _.extend(theme, req.body);
theme.markModified('copyMinNumericalAttsColorNodes');
theme.markModified('copyMaxNumericalAttsColorNodes');
theme.save(function(err, theme) {
if(err) {
console.log(err);
res.status(500).send(err);
} else {
res.json(theme);
}
});
};
我真的很感激任何关于可能产生此错误的想法。谢谢!
答案 0 :(得分:0)
将代码更改为以下似乎可以解决问题:
def temp(x):
return sum(v for k, v in Counter(x).items() if k.lower() in 'aeiuo')