'lookup gives error as from is missing inspite of correct query

For this Model in mongo using mongoose, and query as following : gets error MongoServerError: missing 'from' option to $lookup stage specification: { localField: "vendor", foreignField: "_id", as: "vendors" }

const items = await VendorItem.aggregate([
            {$lookup : { from: Vendor, localField: 'vendor', foreignField: "_id", as: "vendors"}},
            {$group: {categories: '$category'}}
        ]);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source