我尝试使用承诺返回表字段的值,但结果如下所示
router.get("/generateDemand", (req, res, next) => {
const entreprise = req.user.entrepriseid;
downloadFile(req, res, next, entreprise);
});export const downloadFile = async (req, res, next, entreprise) => {
const title1 = await Entreprise.findOne({
attributes: ["entrepriseid", "titrefr"],
where: { entrepriseid: entreprise }
});
console.log("title---------->", chalk.bgBlue(title1));
}……
执行(默认):从“经营企业”中选择"entrepriseid",选择"titrefr“作为”企业“,其中"entreprise”= 'SDA';标题
发布于 2019-07-17 14:57:53
通过调用findOne方法,您将返回一个Sequelize实例,因此为了获得给定实例的指定字段(表记录的表示),您应该使用类似于chalk.bgBlue(title1.get('fieldName'))的instance.get方法
https://stackoverflow.com/questions/57078677
复制相似问题