How to group By counting with TypeOrm Repository help me


const res = await this.jobViewsRepository.createQueryBuilder('jobViews')           
    .addSelect("COUNT(jobViews.user_id) AS jobViews_total_count" )
    .leftJoinAndSelect(Jobs, "jobs", " = jobViews.job_id")
    .where("jobs.user_id != :id", { id: user_id })        
    .orderBy('jobViews_total_count', 'DESC')**


 const result = await this.jobViewsRepository.find({
        relations: ["jobs"],
        loadEagerRelations: true,  
        order: { id: "DESC" },
        skip: offset,
        take: limit,

DATABSE: mysql same question with: Is there a way I can use Group By and Count with Type Orm Repository but it has no answer

Read more here:

Content Attribution

This content was originally published by MRCC at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: