sequelize-typescript 获取子查询的属性

2019-02-25  本文已影响0人  AsaGuo
  1. raw:true
    book.findAndCountAll({
        attributes:['book.*','person.name'],
        raw:true,
        include:[{
            model:person,
            attributes:['name'],
        }]
    }).then(results => {
        console.log("results.rows[0].name:",results.rows[0].name)
    });
  1. raw:false
    book.findAndCountAll({
        attributes:['book.*','person.name'],
        include:[{
            model:person,
            attributes:['name'],
        }]
    }).then(results => {
        console.log("results.rows[0].person.name:",results.rows[0].person.name);
    });
上一篇下一篇

猜你喜欢

热点阅读