"Get de last item of object field list to user record"
Options
![Daniel Rjeili](https://us.v-cdn.net/6037124/user_avatars/1510658.jpg)
Daniel Rjeili
Member ✭
Sorry if the post title is a little bit odd 🙈
I will show step by step what I am doing and what I want to achieve.
I am in right way of there is something simpler or faster ?
[mock001.jpeg][mock002.jpeg]
I need to incorporate this in all user table queries (GET) to have only the user update status id ( lastest ) as a "regular field". All suggestions/brainstormings is welcome 😂 thanks in advance!🙏
Mayday to: 🙂
I will show step by step what I am doing and what I want to achieve.
I am in right way of there is something simpler or faster ?
[mock001.jpeg][mock002.jpeg]
I need to incorporate this in all user table queries (GET) to have only the user update status id ( lastest ) as a "regular field". All suggestions/brainstormings is welcome 😂 thanks in advance!🙏
Mayday to: 🙂
Comments
-
- can you clarify for me? You want to just pull the user record that has the latest status_at field value?
-
, when I query an user ( GET ) I need the response json brings the useraccountstatus_id of the latest status from the user object list accountStatus... as a regular single field from the table like i showed in the last image.
-
Ok. I think I understand now - useraccountstatus_id is nested in an object array of a record and you just want to return the latest object from that? Do you only want that object or do you want it a part of the user record you are pulling?
-
I want it as part of the user I am pulling
example : GET user id = 123
{"id":123,"email":"daniel@xyz.com.br","name":"Daniel","status_at":1632524100000,"usersaccountstatus_id":1,"status_by":94}
or only usersaccountstatus_id (even better):
{"id":123,"email":"daniel@xyz.com.br","name":"Daniel","usersaccountstatus_id":1} -
If I am understanding this correctly, it sounds like this is just a transformation problem. Each user record has all the information it needs, but you want it to be transformed into a more minimal format - is that correct?
If that is correct, then you can do that with just a foreach loop. Here is the pseudocode.
1. Query All Records as users
2. For Each users as user1. Update var:user = var:user|merge( var:user.accountStatus|last)|unset("accountStatus")
The For Each loop uses a reference while it iterates, so you can just update that variable "user" and it will automatically update itself in the array - very convenient.
Then you use the merge filter with the last element and then unset the accountStatus field. -
, i don't need query all records, I just need query specific record Id (GET single record), that brings lastest "usersaccountstatus_id".
-
and , in this last minutes I followed Sean suggestion even with what I answered above. And I reached the result I needed!
[mockup3.png]results:[mockup4.png]
Thanks you both ! 👏 👍
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