I\'m new to mongodb and practice aggregate with $lookup in mongoose following document, And i met a question really confusing.
I have user
The from field in $lookup is the collection name, not a model variable name. So if you are initializing the model like this
db.model('User', userSchema)
then the lookup query should be
commentModel.aggregate([{$lookup: {
from: 'users',
localField: 'author',
foreignField: '_id',
as: 'common'
}])