Remove the first 3 objects in an array
![liam](https://us.v-cdn.net/6037124/uploads/userpics/3H7104LQR226/nMYKMXK20IPV2.png)
I have 10 objects in an array and i want to remove the first 3 object in the array without any condition.
How do i do this ? i've search the docs and forum but could not find the solution.
Answers
-
Have you tried with a "range" filter?
The documentation is here: https://docs.xano.com/working-with-data/data-type-filters/array-filter
In your case it would be start 4 and end 10.
Let me know how it goes
Mariano
-
@dorilama hmmm this requires us to know the length of the array first right ?
what if i don't know the array length ?
it can be 10 objects or 5 objects or 100 objects in array. We need to remove the first three element from that array
-
the filter "count" returns the number of items in an array
-
@dorilama this is how my array looks like this
{"instagram_feeds":[
{"id":"2885669349228547921","type":"GraphVideo","likes":200,}
{"id":"18271872364637463744","type":"GraphVideo","likes":7361,}
{"id":"918291829172918218223","type":"GraphVideo","likes":71161,}
{"id":"62520471524457291283","type":"GraphVideo","likes":261,}
{"id":"012891278172817212333","type":"GraphVideo","likes":161,}
{"id":"09871625182447823783","type":"GraphVideo","likes":741,}
]}
we want to remove the first three objects, is this still possible with range ?
-
Yes, it is possible.
I'm from my phone now but you can read in the docs:
Returns array of values between the specified start/stop.
If you don't know the length in advance tou can use the filter "count" to get it.
Give it a try and let me know how it goes.
-
Hi @ilam It would be great if you can elaborate the use case as well,
According to the above comments I would say :
Get the total number(Count) of object in an array(check if there is any object or not), if there is any object available -> compare the count of object with 3 -> if <=3 delete all else delete first three using 'Range' Function(Specified range will start from 4 and end at 10) like @Dorian A elaborated above.
Give it a try, it should work.
-
@Sahira_Mehta "range" will not delete the items from the array, it will select and return the items in the range
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