Discussion.findAll({
where : {
discussion_on : profileId,
is_deleted : false ,
is_reply : false
},
limit : 5,
order : [['updated_at','DESC']],
offset:5*(page-1),
// order : [['updated_at','DESC']],
include:[{
model : Profile,
as : 'CommentBy',
attributes:staticData.USER_LAYOUT,
include : [{
model : TeamMember,
as : "TeamSender",
required : false,
attributes : ['receiver', 'title'],
where : sequelize.where(sequelize.col('receiver'),db.sequelize.col('discussion.comment_entity'))
},{
model : TeamMember,
required : false,
as : "TeamReceiver",
attributes : ['sender', 'title'],
where : sequelize.where(sequelize.col('CommentBy.TeamReceiver.sender'),db.sequelize.col('discussion.comment_entity'))
}]
},{
model : Discussion,
as : 'Replies',
required : false ,
order : [['Replies.created_at','ASC']],
where : {
is_deleted : false
} ,
include:[{
model : Profile,
as : "CommentBy",
attributes:staticData.USER_LAYOUT,
include : [{
model : TeamMember,
as : "TeamSender",
required : false,
attributes : ['receiver', 'title'],
where : sequelize.where(sequelize.col('Replies.CommentBy.TeamSender.receiver'),db.sequelize.col('Replies.comment_entity'))
},{
model : TeamMember,
required : false,
as : "TeamReceiver",
attributes : ['sender', 'title'],
where : sequelize.where(sequelize.col('Replies.CommentBy.TeamReceiver.sender'),db.sequelize.col('Replies.comment_entity'))
}]
},{
model:Profile,
as : "CommentEntity",
attributes:staticData.USER_LAYOUT
}]
},{
model:Profile,
as : "CommentEntity",
attributes:staticData.USER_LAYOUT
}]
})
讨论是对象名称。 基本上,此查询会将所有注释与每条注释附加的回复一起提取。我希望回复按日期排序。
这是我想在回复中实现的。但它不起作用
订单:[[' created_at',' ASC']],