Is there some way of put count in "with" clause of Query builder?

I made a clone of twitter in AdonisJS and i get “tweets” of this way:

const tweets = await Post.query()   .whereIn('user_id', followersIds)   .with('user')   .with('favorites')   .with('replies')   .orderBy('created_at', 'DESC')   .paginate(params.page, 3) 

The problem is that in this method I get tweet whit all replies tables and I only need the tweet whit count or replies.lenght.

I thought of use a buckle for this but possibly exist another way 4 make this in query builder…

Thanks for the help.

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.