```statsRoute.route("/getPlayerInfos").get(function (req, res) {
让统计信息= User.findOne({名称:req.body.myquery,角色:0,})。populate({路径:“商店”,型号:“商店”,填充:{路径:“ WorldDetails”,模型:“ WorldDetails”},填充:{路径:“游戏”,型号:“游戏”,填充:{路径:“详细信息”,模型:“详细信息”},},})。exec();让myres = statistics.toObject({getters:true});res.render(“ stats”,{myres});});```
您的代码缺少承诺解析。试试这个,
statsRoute.route("/getPlayerInfos").get(async function (req, res) {
let statistics = await User.findOne({
name: req.body.myquery,
role: 0,
}).populate({
path: "Stores",
model: "Store",
populate: { path: "WorldDetails", model: "WorldDetails" },
populate: {
path: "Games",
model: "Game",
populate: { path: "Details", model: "Detail" },
},
}).exec();
// Object
let myres = statistics.toObject({ getters: true });
res.render("stats", { myres });
});