我有两个model Blog,Catalog Blog的代码大致是这样 sequelize.define(“Blog”,{ blogId:{xxx}, catalogId:{xxx}, … } Catalog的代码大致是这样 sequelize.define(“Catalog”,{ catalogId:{xxx}, … } 现在想做关联查询于是我写了他们之间的关系: Blog.belongsTo(Catalog,{foreignKey:‘catalogId’}); Catalog.hasMany(Blog,{as:‘Catalog’});
然而生成的代码是这样的:
SELECT Blog
.blogId
, Blog
.catalogId
, …,Blog
.CatalogCatalogId
, Catalog
.catalogId
AS Catalog.catalogId
,… FROM blog
AS Blog
LEFT OUTER JOIN catalog
AS Catalog
ON Blog
.catalogId
=
Catalog
.catalogId
;
我就想问下为什么会生成一个加粗部分,我是哪里写得有问题?说实话sequelize的文档真的好难看