知道如何在sequelize中使用包含属性的include(当您只需要包含包含的表的特定字段时)吗?

目前我有这个(但它没有按预期工作):

var attributes = ['id', 'name', 'bar.version', ['bar.last_modified', 'changed']];
foo.findAll({
    where      : where,
    attributes : attributes,
    include    : [bar]
}).success(function (result) { ...

推荐答案

这样的办法应该行得通

foo.findAll({
    where      : where,
    attributes : attributes,
    include    : [{ model: bar, attributes: attributes}]
}).success(function (result) {

Node.js相关问答推荐

postgresql层与应用层的序列化

如何在医学中按patientId查找一个并同时插入多个数据

即使卷已设置,Docker Nodemon 也不会热重载

如何在Node.js的telegraf.js命令中添加参数?

我如何保护nodejs中的路由

在 Header 中使用 Authorization 方法和新的附加参数:accessToken 有什么区别?

module.exports=require('other') 和临时变量有什么区别?

使用 create-expo-app 时如何更改 webpack-config.js 中的哈希函数?

带有事件网格的 Azure 函数在没有 ngrok 的情况下在本地运行

WSL2 上需要脚本运行的 NPM 包的权限被拒绝

表达限制资源属于特定用户的优雅方式

添加git信息到create-react-app

具有多个条件的mongoose 查找

使用 pg-promise 进行多行插入

Nodejs续集批量更新

tsconfig.json 中模块类型的区别

什么是 JavaScript 中的REPL?

Node.js - 使用异步库 - 带有对象的 async.foreach

node.js 找不到模块mongodb

Node.js 中的 PHP exit()/die() 类似功能是什么