TypeError: Cannot read property 'populate' of undefined
Mongoose перестал обрабатывать ".populate", выдает ошибку: TypeError: Cannot read property 'populate' of undefined.
Package.json
"dependencies": {
"connect-mongodb-session": "^2.2.1",
"express": "^4.16.4",
"express-handlebars": "^3.0.2",
"express-session": "^1.16.1",
"mongoose": "^5.5.3",
"uuid": "^3.3.2"
}
Models/
const itemSchema = new Schema({
title: String,
price: Number,
userId: {
type: Schema.Types.ObjectId,
ref: 'User'
}
})
App.js
router.get('/', async (req, res) => {
const user = await req.user
.populate('cart.items.itemId')
.execPopulate()
res.render('cart')
})
Подскажите, в чем может быть проблема? Из-за обновления версии mongoose?