我希望在sequelize中使用findAll()而不使用raw:true时获取datavalues
Activities.findAll({ include: [ { all: true } ], }) .then(activities => { });
crcmnpdw1#
如果没有raw:true,你必须循环遍历每个对象并从中获取值,如下所示:
raw:true
Activities.findAll({ include: [{ all: true }], }).then(activities => { return activities.map( activity => el.get({ plain: true }) ); });
或
raw : true,在使用include时生成.名称,这个问题可以通过nest : true解决
raw : true
.
nest : true
Activities.findAll({ raw : true , nest: true , // <--- The issue of raw true, will be solved by this include: [{ all: true }], }).then(activities => { console.log(activities); });
4ktjp1zp2#
这是我在不使用row: true的情况下求解的方法。
row: true
let rows = await Activities.findAll(); rows = JSON.stringify(rows); rows = JSON.parse(rows);
行仅获取数据
2条答案
按热度按时间crcmnpdw1#
如果没有
raw:true
,你必须循环遍历每个对象并从中获取值,如下所示:或
raw : true
,在使用include时生成.
名称,这个问题可以通过nest : true
解决4ktjp1zp2#
这是我在不使用
row: true
的情况下求解的方法。行仅获取数据