result = {};
Promise.all(data2.map(async function(subcat) {
await productModel.find({ subcategory_id: subcat._id }, function(err4, data4) {
result.sub_category = subcat;
result.product = data4;
});
return result;
})).then(www => {
var records = util.inspect(www, false, null, true /* enable colors */);
console.log(records);
});
我无法通过新对象获得结果。请帮助我。