I want to fetch comment counts instead of fetching all comments in a single query, The below code I am using but getting the error
$answers = Answers::project([
'comments'=>0,
'comments_count' => [
'$size' => '$comments'
]])
->where('question_id',$request->question_id)
->get();
Error :- "message": "Unsupported projection option: comments_count: { $size: \"comments\" }",
Is $size aggregate support in jenssegers mongodb laravel package? if yes then that is the correct way to use it,
Thanks.