You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letA=mongoose.model('a',newSchema({}));awaitA.find().populate('id');// `id` is virtual getter of `_id`// throws MongooseError: If you are populating a virtual, you must....
The error is expected. However, the error is thrown in nextTick instead of rejecting the promise, and the process crashed.
C:\...\node_modules\mongoose\lib\utils.js:226
throw error;
^
MongooseError: If you are populating a virtual, you must set the localField and foreignField options
at new MongooseError (C:\...\node_modules\mongoose\lib\error\mongooseError.js:11:11)
at getModelsMapForPopulate (C:\...\node_modules\mongoose\lib\model.js:3947:13)
at populate (C:\...\node_modules\mongoose\lib\model.js:3486:21)
at _populate (C:\...\node_modules\mongoose\lib\model.js:3456:5)
at utils.promiseOrCallback.cb (C:\...\node_modules\mongoose\lib\model.js:3429:5)
at Object.promiseOrCallback (C:\...\node_modules\mongoose\lib\utils.js:223:14)
at Function.Model.populate (C:\...\node_modules\mongoose\lib\model.js:3428:16)
at cb (C:\...\node_modules\mongoose\lib\query.js:1606:17)
at result (C:\...\node_modules\mongodb\lib\utils.js:414:17)
at executeCallback (C:\...\node_modules\mongodb\lib\utils.js:406:9)
at handleCallback (C:\...\node_modules\mongodb\lib\utils.js:128:55)
at cursor.close (C:\...\node_modules\mongodb\lib\operations\cursor_ops.js:218:62)
at handleCallback (C:\...\node_modules\mongodb\lib\utils.js:128:55)
at completeClose (C:\...\node_modules\mongodb\lib\cursor.js:887:14)
at _endSession (C:\...\node_modules\mongodb\lib\cursor.js:898:37)
at Cursor._endSession (C:\...\node_modules\mongodb-core\lib\cursor.js:193:5)
at Cursor._endSession (C:\...\node_modules\mongodb\lib\cursor.js:226:59)
at Cursor.close (C:\...\node_modules\mongodb\lib\cursor.js:898:19)
at cursor._next (C:\...\node_modules\mongodb\lib\operations\cursor_ops.js:218:23)
at handleCallback (C:\...\node_modules\mongodb-core\lib\cursor.js:202:5)
at _setCursorNotifiedImpl (C:\...\node_modules\mongodb-core\lib\cursor.js:560:38)
at self._endSession (C:\...\node_modules\mongodb-core\lib\cursor.js:568:46)
Process finished with exit code 1
I want to report a bug
What is the current behavior?
The error is expected. However, the error is thrown in nextTick instead of rejecting the promise, and the process crashed.
mongoose/lib/utils.js
Lines 220 to 229 in 27cc9e7
If the current behavior is a bug, please provide the steps to reproduce.
Just populate any virtual field without the
localField
andforeignField
options will throw.What is the expected behavior?
The error should either returned in the callback, or reject the promise, but not crashing the process.
Please mention your node.js, mongoose and MongoDB version.
node 8.10.0
mongoose 5.2.5
MongoDB 3.6.1 Community
The text was updated successfully, but these errors were encountered: