mysql - 从sequelize查询中排除主键属性

标签 mysql node.js sequelize.js

我有一个来自多个内部连接在一起的表的 Sequelize 查询。我需要在嵌套的 include 模型上对它们进行分组,但 Sequelize 查询每次都会抛出主键,即使我将属性提到为:attributes:[].

但是 attributes:[] 适用于嵌套 include 模型。

最佳答案

您可以通过将 exclude 数组传递到 attributes 选项来排除任何属性:

MyModel.findAll({
  attributes: {exclude: ['some_field']}
});

关于mysql - 从sequelize查询中排除主键属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49095292/

相关文章:

MySQL : foreign key error

python - MySQL 没有给出错误,但是没有一行被填充

node.js - 无法解析 .../node_modules/geoip-lite/lib 中的模块 'fs'

javascript - 如何使用模块导出来拉出处理程序?

sequelize.js - sequelize - 使用泛型类型从普通对象创建模型

mysql - Laravel 5 中的自定义查询

php - MySQL/PHP : 'AS' xnumber as always positive number

node.js - 需要子文件夹中的 node_module

node.js - 使用 SQLite3 进行单元测试

postgresql - 无法在 Sequelize 中将字符 'N' 插入 PostgreSQL