Mongoose.js保存文件时出现exception,但看似可接受的string值

我得到一个错误从Node.js保存到mongoose.js的文档。 这段代码已经运行良好了一段时间,但它现在导致JavaScript对象与键值看起来很好,否则的问题。

正在保存的是一个文档,其中一个成员是一个关联数组,为简单起见,它们表示为Schema.Types.Mixed

 var formatSchema = new mongoose.Schema({ name: {type: String, required: true}, values: {type: mongoose.Schema.Types.Mixed, required: false} }); 

当一个对象有一个像"0038-"这样的键时,它现在失败了。 具体来说,这是破折号-这是造成这个问题。 如果我把这些值(testing,而不是用户满意度),它加载罚款。 隔了这么远,我们现在难以理解如何进行。

 [ { "name": "INJURYF", "values": { "0": "No", "1": "Yes" } }, { "name": "RFVF", "values": { "10050": "Chills", "10100": "Fever", "10200": "General weakness", "10250": "General ill feeling", "00323": "Salmonella arthritis", "00324": "Salmonella osteomyelitis", "0038-": "Other specified salmonella infections", // PROBLEM STARTS HERE "0039-": "Salmonella infection, unspecified", "0040-": "Shigella dysenteriae", ... } }, ... ] 

这里是具体的错误信息,

 Express 500 TypeError: Cannot call method 'path' of undefined at getPositionalPath (/myproject/node_modules/mongoose/lib/schema.js:380:22) at Schema.path (/myproject/node_modules/mongoose/lib/schema.js:199:9) at Query._getSchema (/myproject/node_modules/mongoose/lib/query.js:1789:27) at Query._walkUpdatePath (/myproject/node_modules/mongoose/lib/query.js:1721:16) at Query._walkUpdatePath (/myproject/node_modules/mongoose/lib/query.js:1716:25) at Query._castUpdate (/myproject/node_modules/mongoose/lib/query.js:1655:23) at castDoc (/myproject/node_modules/mongoose/lib/query.js:2160:18) at Query._findAndModify (/myproject/node_modules/mongoose/lib/query.js:2032:17) at Query.findOneAndUpdate (/myproject/node_modules/mongoose/lib/query.js:1941:15) at Function.Model.findOneAndUpdate (/myproject/node_modules/mongoose/lib/model.js:1127:16) 

mongoose位置操作错误

开始了:

这是一个更老的mongoose版本的错误 – 请更新到最新版本。