I'm trying to go through the ratings array for each object, extract the scores for each inner object and add them into a new array.
For example, the post with post_id: "5e1223c2383ce049d8b32eb5", I need an associated array which would containe [1, 4]. And the post with post_id" "5e146b993dde720850c11c0e" would contain [5] etc.
Help would be much appreciated!
[
    {
        "post_id": "5e1223c2383ce049d8b32eb5",
        "ratings": [
            {
                "_id": "5e134aa9d6c3a51930452d49",
                "user": "5e0f76c96a55d6352879daab",
                "score": 1
            },
            {
                "_id": "5e134c00cab61f408c75d2f2",
                "user": "5e0f34adab4d4b369c57fbd4",
                "score": 4
            }
        ]
    },
    {
        "post_id": "5e13592c62008b4e3435472f",
        "ratings": []
    },
    {
        "post_id": "5e146b993dde720850c11c0e",
        "ratings": [
            {
                "_id": "5e1473583dde720850c11c13",
                "user": "5e0f34adab4d4b369c57fbd4",
                "score": 5
            }
        ]
    }
]
 
     
    