[英]Cannot read property 'castForQuery' of undefined at castArrayFilters in Node.js
I am using arrayFilters as option in findOneAndUpdate (in mongoose ) to update value of name and isRecursive fields in TimetableModel. 我使用arrayFilters在findOneAndUpdate(在猫鼬 )选项来更新 TimetableModel 名称和isRecursive领域的价值。 The fields are updating successfully in MongoDb but also I am getting the exception , which is being added at the end of this query.
字段在MongoDb中 成功更新,但是我也收到了异常 ,该异常正在此查询的末尾添加。
What am I supposed to do to eliminate this exception? 我应该怎么做才能消除此异常?
Following are the details of my work: 以下是我的工作细节:
Versions: "mongodb": "^3.1.13", "mongoose": "^5.4.9",
版本: “ mongodb”:“ ^ 3.1.13”,“ mongoose”:“ ^ 5.4.9”,
this is the Schema: 这是架构:
const timetableSchema = new Schema({
individualId: {
type: Schema.Types.ObjectId,
required: true
},
date: {
type: Number,
required: false
},
time: []});
this is the logic: 这是逻辑:
TimetableModel.findOneAndUpdate({
individualId: req.query.individualId,
date: req.query.date,
}, {
'time.$[i].name': req.query.name,
'time.$[i].isRecursive': req.query.isRecursive,
}, {
arrayFilters: [{
'i.timeSlot': req.query.timeSlot
}],
}, function (err, result) {
if (result) {
resolve(result);
} else if (err) {
reject(err);
}
}).catch((err) => {
reject(err);
})
and this is the exception 这是例外
"TypeError: Cannot read property 'castForQuery' of undefined at castArrayFilters (/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/mongoose/lib/helpers/update/castArrayFilters.js:59:37) at _castArrayFilters (/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/mongoose/lib/query.js:1739:5) at model.Query.Query._findAndModify (/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/mongoose/lib/query.js:3205:3) at model.Query. (/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/mongoose/lib/query.js:2830:8) at model.Query._wrappedThunk [as _findOneAndUpdate] (/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/mongoose/lib/helpers/query/wrapThunk.js:16:8) at process.nextTick (/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/kareem/index.js:369:33) a
“ TypeError:无法读取castArrayFilters中未定义的属性'castForQuery'(/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/mongoose/lib/helpers/update/castArrayFilters.js:59 :37)在model.Query.Query._findAndModify(/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/mongoose/lib/query.js:1739:5)处/Users/user/Desktop/Projects/ParentsPlus/ParentsPlusRepo/parents-plus-back-end/node_modules/mongoose/lib/query.js:3205:3)在model.Query。(/ Users / user / Desktop / Projects /在model.Query._wrappedThunk [as _findOneAndUpdate](/ Users / user / Desktop / Projects / ParentsPlus / ParentsPlusRepo /在process.nextTick(/ Users / user / Desktop / Projects / ParentsPlus / ParentsPlusRepo / parents-plus-back-)上的父母加后端/node_modules/mongoose/lib/helpers/query/wrapThunk.js:16:8)结束/node_modules/kareem/index.js:369:33) t _combinedTickCallback (internal/process/next_tick.js:132:7) at process._tickCallback (internal/process/next_tick.js:181:9)"
t _combinedTickCallback(internal / process / next_tick.js:132:7)在process._tickCallback(internal / process / next_tick.js:181:9)”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.