0
点赞
收藏
分享

微信扫一扫

Typeorm_使用getRawMany 无法分页

静守幸福 2023-03-03 阅读 80


Google半天没啥结果,最后把分页换成了 limit和offset 组合

const topic = this
.createQueryBuilder('post')
.leftJoinAndSelect(Topic, 'topic', 'post.topic_id = topic.id')
.select('topic.id, topic.name')
.addSelect('SUM(1)', 'count')
.groupBy('post.topic_id')
.addGroupBy('topic.id')
.where('post.topic_id is not null AND post.status = :status', { status: PostStatus.Active })
.orderBy('count', sortBy)
// .skip(pageIndex * pageSize)
// .take(pageSize)
.limit(pageSize)
.offset(pageIndex * pageSize)
.getRawMany();

 

举报

相关推荐

0 条评论