使用sequelize针对多对多联结表进行查询时报“Unknown column in field list ”错误

项目场景:

项目开发中用到一个比较经典的用户权限库表设计,关系如下图所示:
在这里插入图片描述
t_user是用户表,t_role是角色表,t_user_role是两者之间的联结表,用户表和角色表是多对多的关系,通过t_user_role表的user_id和role_id进行外键关联。

各表用sequelize的Model定义如下:
1)用户表:

const Model = sequelize.define(
    'User',
    {
   
      id: {
   
        type: DataTypes.CHAR(21),
        allowNull: false,
        primaryKey: true,
        comment: '主键',
      },
      mobile: {
   
        type: DataTypes.STRING(20),
        allowNull: false,
        comment: '手机号码',
        unique: 'ukey',
      },
      name: {
   
        type: DataTypes.STRING(64),
        allowNull: true,
        comment: '姓名',
      },
      job: {
   
        type: DataTypes.STRING(64),
        allowNull: true,
        comment: '职务/职称',
      },
      admin: {
   
        type: DataTypes.BOOLEAN,
        allowNull: true,
        defaultValue: 0,
        comment: '是否系统管理员(0-否 1-是)',
      },
      status: {
   
        type: DataTypes.BOOLEAN,
        allowNull: true,
        defaultValue: 1,
        comment: '状态(0-冻结,1-正常)',
      },
      remark: {
   
        type: DataTypes.STRING(255),
        allowNull: true,
        comment: '备注',
      },
      lastLoginDate: {
   
        type: DataTypes.DATE,
        allowNull: true,
        comment: '最后一次登录时间',
        field: 'last_login_dat
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Delphi 7 – 2006, CodeGear Delphi 2007, RAD Studio 2009, Embarcadero RAD Studio 2010, XE - XE4 What's new in version 6.2 + DropDownForms technology - customizing droped down windows. Typical DropDown window - is the list that appears in the TComboBox control when you click on the edit button with down arrow in the control. New technology of DropDropForms allows you to create forms that appear and work similarly to the drop down list of TComboBox. These forms can be displayed by pressing one of the edit buttons within controls TDBEditEh, TDBNumberEditEh, TInplaceEditor in DBGridEh etc. See detailed description of using DropDownForms in the document ; Section - DropDownForms and See an Example in the: \Demos\DropDownForm\Project1.dpr compiled project: \Demos\Bin\DropDownForm.Exe New properties to customize the drop-down Form are in the following classes: (For DBGridEh) TColumnEh.DropDownFormParam TColumnEh.EditButtons[i].DropDownFormParam (For DBVertGridEh) TFieldRowEh.DropDownFormParam TFieldRowEh.EditButtons[i].DropDownFormParam TDBEditEh.EditButton.DropDownFormParam TDBEditEh.EditButtons[i].DropDownFormParam In EditButtons for TDBNumberEditEh, TDBDateTimeEditEh, TDBComboBoxEh, TDBLookupComboBoxEh controls. (In DBVertGridEh) + Added possibility to group rows into categories. See TDBVertGridEh.RowCategories property. Assign category name in the property TFieldRowEh.CategoryName. The rows can be grouped by: Category Title, Field Type or presence/absence of values in the current record. + Added possibility to sort the rows by the row captions. See property TDBVertGridEh.RowsSortOrder. (В DBGridEh) + In DBGridEh at Design-Time it is allowed to create DB components and assign DataSource and DataSource.DataSet properties. Right-click above the Design-Time panel in the lower right corner of the Grid and select the menu to assign or create a required component.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值