Mongoose returns empty string for $size when lookup is empty array

I have a lookup in my aggregate query. When the lookup result for mySubjects is empty, always the $size returns "" instead of 0. Whenever the mySubjects is non empty, $size is working perfectly. Can anyone help?

{                    
$lookup: {
    from: 'subjects',
    let: { userId: "$_id"},
    pipeline: [
        { 
            $match: {  
                $expr: {
                    $and: [
                        { $eq: [ "$$userId", "$userId" ] },
                    ]
                } 
            }
        },
    ],
    as: 'mySubjects'
},
},
{
 $set: {
    mySubjectCount: { $cond: { if: { $isArray: "$mySubjects" }, then: { $size: "$mySubjects" }, else: 0} }
}
},

A sample result looks like

   [ 
       {
            "id": "609a9113fd45997a407c9509",
            "mySubjects": [],
            "mySubjectCount": "",
       },
       {
            "id": "609a9113fd56997a407c9587",
            "mySubjects": ["test","test"],
            "mySubjectCount": 2,
       },
   ]
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum