让我们说我有这个数据库标准对象-
let criteria = {
limit: limit,
offset: offset,
include: [
{
model: Comments,
include: [
{
model: User.scope('public')
},
{
model: Likes
}
]
},
{
model: User.scope('public')
},
{
model: AdOptions,
},
{
model: Images,
},
{
model: Questions,
},
{
model: Likes,
},
{
model: Videos
},
{
model: Tags
}
] ,
/*
* Get only those posts which are from user's friends, public, self created or ads
*/
where: {
[op.or]: [
{
UserId: friendIds
},
{
AdOptionId: { [op.ne]: null}
},
{
public: { [op.eq]: true},
'$Tags.id$': TagsIdsArray
}
]}
};
我这样使用它-
Posts.findAll(criteria)
。
我收到以下错误-
{"name":"SequelizeDatabaseError","parent":{"code":"ER_BAD_FIELD_ERROR","errno":1054,"sqlState":"42S22","sqlMessage":"Unknown column 'Tags.id' in 'where clause'","sql":"SELECT `Posts`.*, `Comments`.`id` AS `Comments.id`, `Comments`.`type` AS `Comments.type`, `Comments`.`comment` AS `Comments.comment`, `Comments`.`createdAt` AS `Comments.createdAt`, `Comments`.`updatedAt` AS `Comments.updatedAt`, `Comments`.`PostId` AS `Comments.PostId`, `Comments`.`UserId` AS `Comments.UserId`, `Comments->PostComments`.`createdAt` AS `Comments.PostComments.createdAt`, `Comments->PostComments`.`updatedAt` AS `Comments.PostComments.updatedAt`, `Comments->PostComments`.`PostId` AS `Comments.PostComments.PostId`, `Comments->PostComments`.`CommentId` AS `Comments.PostComments.CommentId`, `Comments->User`.`id` AS `Comments.User.id`, `Comments->User`.`first` AS `Comments.User.first`, `Comments->User`.`last` AS `Comments.User.last`, `Comments->User`.`phone` AS `Comments.User.phone`, `Comments->User`.`pic` AS `Comments.User.pic`, `Comments->Likes`.`id` AS `Comments.Likes.id`, `Comments->Likes`.`createdAt` AS `Comments.Likes.createdAt`, `Comments->Likes`.`updatedAt` AS `Comments.Likes.updatedAt`, `Comments->Likes`.`UserId` AS `Comments.Likes.UserId`, `Comments->Likes`.`PostId` AS `Comments.Likes.PostId`, `Comments->Likes`.`CommentId` AS `Comments.Likes.CommentId`, `Comments->Likes->CommentLikes`.`createdAt` AS `Comments.Likes.CommentLikes.createdAt`, `Comments->Likes->CommentLikes`.`updatedAt` AS `Comments.Likes.CommentLikes.updatedAt`, `Comments->Likes->CommentLikes`.`CommentId` AS `Comments.Likes.CommentLikes.CommentId`, `Comments->Likes->CommentLikes`.`LikeId` AS `Comments.Likes.CommentLikes.LikeId`, `User`.`id` AS `User.id`, `User`.`first` AS `User.first`, `User`.`last` AS `User.last`, `User`.`phone` AS `User.phone`, `User`.`pic` AS `User.pic`, `AdOption`.`id` AS `AdOption.id`, `AdOption`.`postIsAd` AS `AdOption.postIsAd`, `AdOption`.`cpc` AS `AdOption.cpc`, `AdOption`.`cpv` AS `AdOption.cpv`, `AdOption`.`clickURL` AS `AdOption.clickURL`, `AdOption`.`createdAt` AS `AdOption.createdAt`, `AdOption`.`updatedAt` AS `AdOption.updatedAt`, `AdOption`.`UserId` AS `AdOption.UserId`, `Images`.`id` AS `Images.id`, `Images`.`path` AS `Images.path`, `Images`.`createdAt` AS `Images.createdAt`, `Images`.`updatedAt` AS `Images.updatedAt`, `Images`.`UserId` AS `Images.UserId`, `Images`.`PostId` AS `Images.PostId`, `Images->PostImages`.`createdAt` AS `Images.PostImages.createdAt`, `Images->PostImages`.`updatedAt` AS `Images.PostImages.updatedAt`, `Images->PostImages`.`PostId` AS `Images.PostImages.PostId`, `Images->PostImages`.`ImageId` AS `Images.PostImages.ImageId`, `Question`.`id` AS `Question.id`, `Question`.`question` AS `Question.question`, `Question`.`description` AS `Question.description`, `Question`.`createdAt` AS `Question.createdAt`, `Question`.`updatedAt` AS `Question.updatedAt`, `Question`.`UserId` AS `Question.UserId`, `Likes`.`id` AS `Likes.id`, `Likes`.`createdAt` AS `Likes.createdAt`, `Likes`.`updatedAt` AS `Likes.updatedAt`, `Likes`.`UserId` AS `Likes.UserId`, `Likes`.`PostId` AS `Likes.PostId`, `Likes`.`CommentId` AS `Likes.CommentId`, `Likes->PostLikes`.`createdAt` AS `Likes.PostLikes.createdAt`, `Likes->PostLikes`.`updatedAt` AS `Likes.PostLikes.updatedAt`, `Likes->PostLikes`.`PostId` AS `Likes.PostLikes.PostId`, `Likes->PostLikes`.`LikeId` AS `Likes.PostLikes.LikeId`, `Video`.`id` AS `Video.id`, `Video`.`title` AS `Video.title`, `Video`.`description` AS `Video.description`, `Video`.`path` AS `Video.path`, `Video`.`createdAt` AS `Video.createdAt`, `Video`.`updatedAt` AS `Video.updatedAt`, `Video`.`UserId` AS `Video.UserId`, `Tags`.`id` AS `Tags.id`, `Tags`.`name` AS `Tags.name`, `Tags`.`icon` AS `Tags.icon`, `Tags`.`UserId` AS `Tags.UserId`, `Tags`.`createdAt` AS `Tags.createdAt`, `Tags`.`updatedAt` AS `Tags.updatedAt`, `Tags->PostsTags`.`createdAt` AS `Tags.PostsTags.createdAt`, `Tags->PostsTags`.`updatedAt` AS `Tags.PostsTags.updatedAt`, `Tags->PostsTags`.`PostId` AS `Tags.PostsTags.PostId`, `Tags->PostsTags`.`TagId` AS `Tags.PostsTags.TagId` FROM (SELECT `Posts`.`id`, `Posts`.`type`, `Posts`.`content`, `Posts`.`public`, `Posts`.`createdAt`, `Posts`.`updatedAt`, `Posts`.`UserId`, `Posts`.`QuestionId`, `Posts`.`AdOptionId`, `Posts`.`VideoId` FROM `Posts` AS `Posts` WHERE (`Posts`.`UserId` IN (1) OR `Posts`.`AdOptionId` IS NOT NULL OR (`Posts`.`public` = true AND `Tags`.`id` IN (1))) ORDER BY `Posts`.`updatedAt` DESC LIMIT 0, 10) AS `Posts` LEFT OUTER JOIN ( `PostComments` AS `Comments->PostComments` INNER JOIN `Comments` AS `Comments` ON `Comments`.`id` = `Comments->PostComments`.`CommentId`) ON `Posts`.`id` = `Comments->PostComments`.`PostId` LEFT OUTER JOIN `Users` AS `Comments->User` ON `Comments`.`UserId` = `Comments->User`.`id` LEFT OUTER JOIN ( `CommentLikes` AS `Comments->Likes->CommentLikes` INNER JOIN `Likes` AS `Comments->Likes` ON `Comments->Likes`.`id` = `Comments->Likes->CommentLikes`.`LikeId`) ON `Comments`.`id` = `Comments->Likes->CommentLikes`.`CommentId` LEFT OUTER JOIN `Users` AS `User` ON `Posts`.`UserId` = `User`.`id` LEFT OUTER JOIN `AdOptions` AS `AdOption` ON `Posts`.`AdOptionId` = `AdOption`.`id` LEFT OUTER JOIN ( `PostImages` AS `Images->PostImages` INNER JOIN `Images` AS `Images` ON `Images`.`id` = `Images->PostImages`.`ImageId`) ON `Posts`.`id` = `Images->PostImages`.`PostId` LEFT OUTER JOIN `Questions` AS `Question` ON `Posts`.`QuestionId` = `Question`.`id` LEFT OUTER JOIN ( `PostLikes` AS `Likes->PostLikes` INNER JOIN `Likes` AS `Likes` ON `Likes`.`id` = `Likes->PostLikes`.`LikeId`) ON `Posts`.`id` = `Likes->PostLikes`.`PostId` LEFT OUTER JOIN `Videos` AS `Video` ON `Posts`.`VideoId` = `Video`.`id` LEFT OUTER JOIN ( `PostsTags` AS `Tags->PostsTags` INNER JOIN `Tags` AS `Tags` ON `Tags`.`id` = `Tags->PostsTags`.`TagId`) ON `Posts`.`id` = `Tags->PostsTags`.`PostId` ORDER BY `Posts`.`updatedAt` DESC;"},"original":{"code":"ER_BAD_FIELD_ERROR","errno":1054,"sqlState":"42S22","sqlMessage":"Unknown column 'Tags.id' in 'where clause'","sql":"SELECT `Posts`.*, `Comments`.`id` AS `Comments.id`, `Comments`.`type` AS `Comments.type`, `Comments`.`comment` AS `Comments.comment`, `Comments`.`createdAt` AS `Comments.createdAt`, `Comments`.`updatedAt` AS `Comments.updatedAt`, `Comments`.`PostId` AS `Comments.PostId`, `Comments`.`UserId` AS `Comments.UserId`, `Comments->PostComments`.`createdAt` AS `Comments.PostComments.createdAt`, `Comments->PostComments`.`updatedAt` AS `Comments.PostComments.updatedAt`, `Comments->PostComments`.`PostId` AS `Comments.PostComments.PostId`, `Comments->PostComments`.`CommentId` AS `Comments.PostComments.CommentId`, `Comments->User`.`id` AS `Comments.User.id`, `Comments->User`.`first` AS `Comments.User.first`, `Comments->User`.`last` AS `Comments.User.last`, `Comments->User`.`phone` AS `Comments.User.phone`, `Comments->User`.`pic` AS `Comments.User.pic`, `Comments->Likes`.`id` AS `Comments.Likes.id`, `Comments->Likes`.`createdAt` AS `Comments.Likes.createdAt`, `Comments->Likes`.`updatedAt` AS `Comments.Likes.updatedAt`, `Comments->Likes`.`UserId` AS `Comments.Likes.UserId`, `Comments->Likes`.`PostId` AS `Comments.Likes.PostId`, `Comments->Likes`.`CommentId` AS `Comments.Likes.CommentId`, `Comments->Likes->CommentLikes`.`createdAt` AS `Comments.Likes.CommentLikes.createdAt`, `Comments->Likes->CommentLikes`.`updatedAt` AS `Comments.Likes.CommentLikes.updatedAt`, `Comments->Likes->CommentLikes`.`CommentId` AS `Comments.Likes.CommentLikes.CommentId`, `Comments->Likes->CommentLikes`.`LikeId` AS `Comments.Likes.CommentLikes.LikeId`, `User`.`id` AS `User.id`, `User`.`first` AS `User.first`, `User`.`last` AS `User.last`, `User`.`phone` AS `User.phone`, `User`.`pic` AS `User.pic`, `AdOption`.`id` AS `AdOption.id`, `AdOption`.`postIsAd` AS `AdOption.postIsAd`, `AdOption`.`cpc` AS `AdOption.cpc`, `AdOption`.`cpv` AS `AdOption.cpv`, `AdOption`.`clickURL` AS `AdOption.clickURL`, `AdOption`.`createdAt` AS `AdOption.createdAt`, `AdOption`.`updatedAt` AS `AdOption.updatedAt`, `AdOption`.`UserId` AS `AdOption.UserId`, `Images`.`id` AS `Images.id`, `Images`.`path` AS `Images.path`, `Images`.`createdAt` AS `Images.createdAt`, `Images`.`updatedAt` AS `Images.updatedAt`, `Images`.`UserId` AS `Images.UserId`, `Images`.`PostId` AS `Images.PostId`, `Images->PostImages`.`createdAt` AS `Images.PostImages.createdAt`, `Images->PostImages`.`updatedAt` AS `Images.PostImages.updatedAt`, `Images->PostImages`.`PostId` AS `Images.PostImages.PostId`, `Images->PostImages`.`ImageId` AS `Images.PostImages.ImageId`, `Question`.`id` AS `Question.id`, `Question`.`question` AS `Question.question`, `Question`.`description` AS `Question.description`, `Question`.`createdAt` AS `Question.createdAt`, `Question`.`updatedAt` AS `Question.updatedAt`, `Question`.`UserId` AS `Question.UserId`, `Likes`.`id` AS `Likes.id`, `Likes`.`createdAt` AS `Likes.createdAt`, `Likes`.`updatedAt` AS `Likes.updatedAt`, `Likes`.`UserId` AS `Likes.UserId`, `Likes`.`PostId` AS `Likes.PostId`, `Likes`.`CommentId` AS `Likes.CommentId`, `Likes->PostLikes`.`createdAt` AS `Likes.PostLikes.createdAt`, `Likes->PostLikes`.`updatedAt` AS `Likes.PostLikes.updatedAt`, `Likes->PostLikes`.`PostId` AS `Likes.PostLikes.PostId`, `Likes->PostLikes`.`LikeId` AS `Likes.PostLikes.LikeId`, `Video`.`id` AS `Video.id`, `Video`.`title` AS `Video.title`, `Video`.`description` AS `Video.description`, `Video`.`path` AS `Video.path`, `Video`.`createdAt` AS `Video.createdAt`, `Video`.`updatedAt` AS `Video.updatedAt`, `Video`.`UserId` AS `Video.UserId`, `Tags`.`id` AS `Tags.id`, `Tags`.`name` AS `Tags.name`, `Tags`.`icon` AS `Tags.icon`, `Tags`.`UserId` AS `Tags.UserId`, `Tags`.`createdAt` AS `Tags.createdAt`, `Tags`.`updatedAt` AS `Tags.updatedAt`, `Tags->PostsTags`.`createdAt` AS `Tags.PostsTags.createdAt`, `Tags->PostsTags`.`updatedAt` AS `Tags.PostsTags.updatedAt`, `Tags->PostsTags`.`PostId` AS `Tags.PostsTags.PostId`, `Tags->PostsTags`.`TagId` AS `Tags.PostsTags.TagId` FROM (SELECT `Posts`.`id`, `Posts`.`type`, `Posts`.`content`, `Posts`.`public`, `Posts`.`createdAt`, `Posts`.`updatedAt`, `Posts`.`UserId`, `Posts`.`QuestionId`, `Posts`.`AdOptionId`, `Posts`.`VideoId` FROM `Posts` AS `Posts` WHERE (`Posts`.`UserId` IN (1) OR `Posts`.`AdOptionId` IS NOT NULL OR (`Posts`.`public` = true AND `Tags`.`id` IN (1))) ORDER BY `Posts`.`updatedAt` DESC LIMIT 0, 10) AS `Posts` LEFT OUTER JOIN ( `PostComments` AS `Comments->PostComments` INNER JOIN `Comments` AS `Comments` ON `Comments`.`id` = `Comments->PostComments`.`CommentId`) ON `Posts`.`id` = `Comments->PostComments`.`PostId` LEFT OUTER JOIN `Users` AS `Comments->User` ON `Comments`.`UserId` = `Comments->User`.`id` LEFT OUTER JOIN ( `CommentLikes` AS `Comments->Likes->CommentLikes` INNER JOIN `Likes` AS `Comments->Likes` ON `Comments->Likes`.`id` = `Comments->Likes->CommentLikes`.`LikeId`) ON `Comments`.`id` = `Comments->Likes->CommentLikes`.`CommentId` LEFT OUTER JOIN `Users` AS `User` ON `Posts`.`UserId` = `User`.`id` LEFT OUTER JOIN `AdOptions` AS `AdOption` ON `Posts`.`AdOptionId` = `AdOption`.`id` LEFT OUTER JOIN ( `PostImages` AS `Images->PostImages` INNER JOIN `Images` AS `Images` ON `Images`.`id` = `Images->PostImages`.`ImageId`) ON `Posts`.`id` = `Images->PostImages`.`PostId` LEFT OUTER JOIN `Questions` AS `Question` ON `Posts`.`QuestionId` = `Question`.`id` LEFT OUTER JOIN ( `PostLikes` AS `Likes->PostLikes` INNER JOIN `Likes` AS `Likes` ON `Likes`.`id` = `Likes->PostLikes`.`LikeId`) ON `Posts`.`id` = `Likes->PostLikes`.`PostId` LEFT OUTER JOIN `Videos` AS `Video` ON `Posts`.`VideoId` = `Video`.`id` LEFT OUTER JOIN ( `PostsTags` AS `Tags->PostsTags` INNER JOIN `Tags` AS `Tags` ON `Tags`.`id` = `Tags->PostsTags`.`TagId`) ON `Posts`.`id` = `Tags->PostsTags`.`PostId` ORDER BY `Posts`.`updatedAt` DESC;"},"sql":"SELECT `Posts`.*, `Comments`.`id` AS `Comments.id`, `Comments`.`type` AS `Comments.type`, `Comments`.`comment` AS `Comments.comment`, `Comments`.`createdAt` AS `Comments.createdAt`, `Comments`.`updatedAt` AS `Comments.updatedAt`, `Comments`.`PostId` AS `Comments.PostId`, `Comments`.`UserId` AS `Comments.UserId`, `Comments->PostComments`.`createdAt` AS `Comments.PostComments.createdAt`, `Comments->PostComments`.`updatedAt` AS `Comments.PostComments.updatedAt`, `Comments->PostComments`.`PostId` AS `Comments.PostComments.PostId`, `Comments->PostComments`.`CommentId` AS `Comments.PostComments.CommentId`, `Comments->User`.`id` AS `Comments.User.id`, `Comments->User`.`first` AS `Comments.User.first`, `Comments->User`.`last` AS `Comments.User.last`, `Comments->User`.`phone` AS `Comments.User.phone`, `Comments->User`.`pic` AS `Comments.User.pic`, `Comments->Likes`.`id` AS `Comments.Likes.id`, `Comments->Likes`.`createdAt` AS `Comments.Likes.createdAt`, `Comments->Likes`.`updatedAt` AS `Comments.Likes.updatedAt`, `Comments->Likes`.`UserId` AS `Comments.Likes.UserId`, `Comments->Likes`.`PostId` AS `Comments.Likes.PostId`, `Comments->Likes`.`CommentId` AS `Comments.Likes.CommentId`, `Comments->Likes->CommentLikes`.`createdAt` AS `Comments.Likes.CommentLikes.createdAt`, `Comments->Likes->CommentLikes`.`updatedAt` AS `Comments.Likes.CommentLikes.updatedAt`, `Comments->Likes->CommentLikes`.`CommentId` AS `Comments.Likes.CommentLikes.CommentId`, `Comments->Likes->CommentLikes`.`LikeId` AS `Comments.Likes.CommentLikes.LikeId`, `User`.`id` AS `User.id`, `User`.`first` AS `User.first`, `User`.`last` AS `User.last`, `User`.`phone` AS `User.phone`, `User`.`pic` AS `User.pic`, `AdOption`.`id` AS `AdOption.id`, `AdOption`.`postIsAd` AS `AdOption.postIsAd`, `AdOption`.`cpc` AS `AdOption.cpc`, `AdOption`.`cpv` AS `AdOption.cpv`, `AdOption`.`clickURL` AS `AdOption.clickURL`, `AdOption`.`createdAt` AS `AdOption.createdAt`, `AdOption`.`updatedAt` AS `AdOption.updatedAt`, `AdOption`.`UserId` AS `AdOption.UserId`, `Images`.`id` AS `Images.id`, `Images`.`path` AS `Images.path`, `Images`.`createdAt` AS `Images.createdAt`, `Images`.`updatedAt` AS `Images.updatedAt`, `Images`.`UserId` AS `Images.UserId`, `Images`.`PostId` AS `Images.PostId`, `Images->PostImages`.`createdAt` AS `Images.PostImages.createdAt`, `Images->PostImages`.`updatedAt` AS `Images.PostImages.updatedAt`, `Images->PostImages`.`PostId` AS `Images.PostImages.PostId`, `Images->PostImages`.`ImageId` AS `Images.PostImages.ImageId`, `Question`.`id` AS `Question.id`, `Question`.`question` AS `Question.question`, `Question`.`description` AS `Question.description`, `Question`.`createdAt` AS `Question.createdAt`, `Question`.`updatedAt` AS `Question.updatedAt`, `Question`.`UserId` AS `Question.UserId`, `Likes`.`id` AS `Likes.id`, `Likes`.`createdAt` AS `Likes.createdAt`, `Likes`.`updatedAt` AS `Likes.updatedAt`, `Likes`.`UserId` AS `Likes.UserId`, `Likes`.`PostId` AS `Likes.PostId`, `Likes`.`CommentId` AS `Likes.CommentId`, `Likes->PostLikes`.`createdAt` AS `Likes.PostLikes.createdAt`, `Likes->PostLikes`.`updatedAt` AS `Likes.PostLikes.updatedAt`, `Likes->PostLikes`.`PostId` AS `Likes.PostLikes.PostId`, `Likes->PostLikes`.`LikeId` AS `Likes.PostLikes.LikeId`, `Video`.`id` AS `Video.id`, `Video`.`title` AS `Video.title`, `Video`.`description` AS `Video.description`, `Video`.`path` AS `Video.path`, `Video`.`createdAt` AS `Video.createdAt`, `Video`.`updatedAt` AS `Video.updatedAt`, `Video`.`UserId` AS `Video.UserId`, `Tags`.`id` AS `Tags.id`, `Tags`.`name` AS `Tags.name`, `Tags`.`icon` AS `Tags.icon`, `Tags`.`UserId` AS `Tags.UserId`, `Tags`.`createdAt` AS `Tags.createdAt`, `Tags`.`updatedAt` AS `Tags.updatedAt`, `Tags->PostsTags`.`createdAt` AS `Tags.PostsTags.createdAt`, `Tags->PostsTags`.`updatedAt` AS `Tags.PostsTags.updatedAt`, `Tags->PostsTags`.`PostId` AS `Tags.PostsTags.PostId`, `Tags->PostsTags`.`TagId` AS `Tags.PostsTags.TagId` FROM (SELECT `Posts`.`id`, `Posts`.`type`, `Posts`.`content`, `Posts`.`public`, `Posts`.`createdAt`, `Posts`.`updatedAt`, `Posts`.`UserId`, `Posts`.`QuestionId`, `Posts`.`AdOptionId`, `Posts`.`VideoId` FROM `Posts` AS `Posts` WHERE (`Posts`.`UserId` IN (1) OR `Posts`.`AdOptionId` IS NOT NULL OR (`Posts`.`public` = true AND `Tags`.`id` IN (1))) ORDER BY `Posts`.`updatedAt` DESC LIMIT 0, 10) AS `Posts` LEFT OUTER JOIN ( `PostComments` AS `Comments->PostComments` INNER JOIN `Comments` AS `Comments` ON `Comments`.`id` = `Comments->PostComments`.`CommentId`) ON `Posts`.`id` = `Comments->PostComments`.`PostId` LEFT OUTER JOIN `Users` AS `Comments->User` ON `Comments`.`UserId` = `Comments->User`.`id` LEFT OUTER JOIN ( `CommentLikes` AS `Comments->Likes->CommentLikes` INNER JOIN `Likes` AS `Comments->Likes` ON `Comments->Likes`.`id` = `Comments->Likes->CommentLikes`.`LikeId`) ON `Comments`.`id` = `Comments->Likes->CommentLikes`.`CommentId` LEFT OUTER JOIN `Users` AS `User` ON `Posts`.`UserId` = `User`.`id` LEFT OUTER JOIN `AdOptions` AS `AdOption` ON `Posts`.`AdOptionId` = `AdOption`.`id` LEFT OUTER JOIN ( `PostImages` AS `Images->PostImages` INNER JOIN `Images` AS `Images` ON `Images`.`id` = `Images->PostImages`.`ImageId`) ON `Posts`.`id` = `Images->PostImages`.`PostId` LEFT OUTER JOIN `Questions` AS `Question` ON `Posts`.`QuestionId` = `Question`.`id` LEFT OUTER JOIN ( `PostLikes` AS `Likes->PostLikes` INNER JOIN `Likes` AS `Likes` ON `Likes`.`id` = `Likes->PostLikes`.`LikeId`) ON `Posts`.`id` = `Likes->PostLikes`.`PostId` LEFT OUTER JOIN `Videos` AS `Video` ON `Posts`.`VideoId` = `Video`.`id` LEFT OUTER JOIN ( `PostsTags` AS `Tags->PostsTags` INNER JOIN `Tags` AS `Tags` ON `Tags`.`id` = `Tags->PostsTags`.`TagId`) ON `Posts`.`id` = `Tags->PostsTags`.`PostId` ORDER BY `Posts`.`updatedAt` DESC;","success":true}
为什么我在“ where子句”中收到“未知列” Tags.id”错误?
请帮助。希望我提供了足够的信息,如果没有,请让我知道您是否还想知道其他信息?谢谢!
答案 0 :(得分:0)
我解决了这个问题。我发现由于父模型中使用的限制和偏移量参数,在父项的where子句中引用子模型/表的列中断了查询(很抱歉,在原始问题中未发布限制和偏移量代码片段,我编辑了问题并添加现在)。
因此,我通过调整ORDER参数并在其中包含限制和偏移量找到了一种骇人听闻的方法。
因此,从父级中删除Limit和Offset参数并将ORDER参数更改为此解决了我的问题-
order: Sequelize.literal('updatedAt DESC LIMIT '+ offset + ',' + limit),