从Sequelize ORM仅获取dataValues [英] Get only dataValues from Sequelize ORM

查看:1042
本文介绍了从Sequelize ORM仅获取dataValues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用序列化ORM从PSQL DB中获取数据.但是,当我检索某些东西时,会给出一堆数据.我想要的唯一数据是在"dataValues"内部.当然,我可以使用object.dataValues.但是,还有其他好的解决方案吗?

I'm using the sequelize ORM to fetch data from a PSQL DB. However, when I retrieve something, a whole bunch of data is given. The only data I want is inside 'dataValues'. Of course, I can use object.dataValues. But, is there any other good solutions?

我正在使用Sequelize 4.10

I'm using Sequelize 4.10

推荐答案

仅当我使用以下方式记录问题时,才会出现此问题:

The problem occurs only when I log it using:

console.log(Model.findAll());

console.log(Model.findAll());

如果将其保存到变量中,则可以直接访问其中的对象,而无需使用" dataValues "

If I save it to a variable, I can directly access objects inside without using "dataValues"

这篇关于从Sequelize ORM仅获取dataValues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆