How to fetch data within object array?
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
-
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
-
Hi,
From the top of my head, you can try to use flatten filter to get single level array.
-
Thank you, I tried the flatten filter, and it put everything in one large array, but I also want to know the properties of the post's text and images. Is there a way to use the flatten filter and still have the properties of each piece of the array? I provided a picture of all the properties of the posts.
-
Thank you, Pawel Magdanski. I will consider creating a separate table for posts.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback