'MongoDB Aggregation converts properties type of array to string

Im getting random data from my database using aggragate but its converting its array properties to string

 const book = await Book.aggregate([
    {       
        $sample: { size: 6 } }
    ]);

desired result

{"title": "Analysis, Vol I", "author": "Tao, Terence", "genre": [ "mathematics" ],}

Result im getting

"title": "Analysis, Vol I", "author": "Tao, Terence", "genre": "mathematics"

How can I fix this? I want get array from the genre so that I can loop through it



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source