How to fetch data within object array?

Options

Hello, I am currently having a problem trying to fetch all users’ posts. I have a nested database where everything is within one table. The table looks like this:
{
Username
Email
Password
Posts [{
Text
Image
Tags
Comments [{
User_id
Text
}]
}]
}
The user can have multiple posts. I will provide my function stack and the results. Right now, I have six users, but there are eight posts. Is it possible to extract and return the eight posts?

Best Answer

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Answer ✓
    Options

    If you want to often access all the posts or filter them or pretty much do anything outside of getting a post of a particular user, then I would consider creating a separate table for the posts related to the user table. Then you can easily query and manipulate the posts

Answers