Node.js 在sequelize中设置模型时,列名使用别名

Node.js 在sequelize中设置模型时,列名使用别名,node.js,orm,sequelize.js,Node.js,Orm,Sequelize.js,我是新加入sequelize的,我尝试在现有的node/express项目中实现 到目前为止,我有一个简单的模型,当我查询它时,它可以工作 const User = sequelize.define('AppUser', { // attributes idUser: { type: Sequelize.INTEGER, allowNull: false, primaryKey: true } }); 因此,名为AppUse

我是新加入sequelize的,我尝试在现有的node/express项目中实现

到目前为止,我有一个简单的模型,当我查询它时,它可以工作

  const User = sequelize.define('AppUser', {
    // attributes
    idUser: {
      type: Sequelize.INTEGER,
      allowNull: false,
      primaryKey: true
    } 
  });
因此,名为AppUser的表(其主键名为idUser)现在是用户模型

用户模型的id为idUser,与AppUser表相同

如果我更改到另一个表的映射,比如webUser,并且id是webId,那么我必须在所有查询中从idUser更改为webUser。那么,在一个地方绘制地图有什么意义呢

我应该可以做一些类似伪代码的事情

  const User = sequelize.define('webUser', {
    // attributes
    id AS idUser or webUser or whatever: {
      type: Sequelize.INTEGER,
      allowNull: false,
      primaryKey: true
    } 
  });
关于列映射,我遗漏了什么

谢谢

只需使用野外道具:

应用程序用户

// attributes
    id: {
      field: 'idUser',
      type: Sequelize.INTEGER,
      allowNull: false,
      primaryKey: true
    } 
网络用户

// attributes
    id: {
      field: 'webId',
      type: Sequelize.INTEGER,
      allowNull: false,
      primaryKey: true
    }