首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从表的字段返回值

从表的字段返回值
EN

Stack Overflow用户
提问于 2019-07-17 14:50:34
回答 1查看 50关注 0票数 0

我尝试使用承诺返回表字段的值,但结果如下所示

代码语言:javascript
复制
router.get("/generateDemand", (req, res, next) => {
  const entreprise = req.user.entrepriseid;

  downloadFile(req, res, next, entreprise);
});
代码语言:javascript
复制
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';标题

EN

回答 1

Stack Overflow用户

发布于 2019-07-17 14:57:53

通过调用findOne方法,您将返回一个Sequelize实例,因此为了获得给定实例的指定字段(表记录的表示),您应该使用类似于chalk.bgBlue(title1.get('fieldName'))instance.get方法

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57078677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档