# Recursive function to look up multiple occurrences of data in a Firebase/JSON structure

**URL:** <https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235>\
**Category:** Questions about Thunkable X\
**Tags:** firebase, json, for-each\
**Created:** [May 10, 2022, 4:01pm UTC](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235 "2022-05-10T16:01:19Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![paulovaz72](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/paulovaz72/32/119071_2.png) [@paulovaz72](https://community.thunkable.com/u/paulovaz72)\
**Post date:** [May 11, 2022, 2:28pm UTC](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235/21 "2022-05-11T14:28:17Z")

</div>

W-O-W-W-W-W-W 😮

YOU ARE AMAZING!!! You did it! 🤓

Thank you very much my friend! For me this is really a depper level of programming (forget the NO-CODE here 😊)

And just to put my 2 cents in this discussion, following the updated version of your project that add the full path of the object (as I need to show in my project):

[https://x.thunkable.com/copy/f2e9446a2efbe77aa0c74902cb70e1d5](https://x.thunkable.com/copy/f2e9446a2efbe77aa0c74902cb70e1d5)

The final result is exactly my comment above:

 ![Captura de tela de 2022-05-11 11-49-10](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/3/b320365c312a2f7972425c92bf81bfa8a856e15f.png)

Again: THANK YOU VERY MUCH!

With my best regards,

Paulo Vaz

[UPDATE 1] - A small fix in the project, to show the path correctly, link changed!

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [May 11, 2022, 4:06pm UTC](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235/22 "2022-05-11T16:06:15Z")

</div>

> [@paulovaz72](#):
>
> W-O-W-W-W-W-W 😮
> 
> YOU ARE AMAZING!!!

totally agree! thank you, @muneer !

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [May 11, 2022, 4:46pm UTC](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235/23 "2022-05-11T16:46:31Z")

</div>

if you add path as a parameter to searchName and update it as you recurse, you don’t have to worry about trimming the last node off the path when you pop out of recursion at any level - it will take care of itself.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/a/9a63bd759c3c2f5b2b55a1a90e4d5ecb637fb90e.png)

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [May 11, 2022, 5:00pm UTC](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235/24 "2022-05-11T17:00:22Z")

</div>

i see what you did there! (using object properties and testing for ‘[object Object]’! CLEVER!)

---

<div class="post-metadata">

**Author:** ![paulovaz72](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/paulovaz72/32/119071_2.png) [@paulovaz72](https://community.thunkable.com/u/paulovaz72)\
**Post date:** [May 11, 2022, 5:22pm UTC](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235/25 "2022-05-11T17:22:50Z")

</div>

Yes! See my (bad) example above…

This is a simple trick to discover if the object is a bucket or a simple value (no nested objects below)… This was something I discovered empirically testing when showing in the screen the results of a cloud variable. And it works!

For sure @muneer knows this very well 🙂

That’s are the things we need learn to reach the next level in APP development, and just because this community help, I’m moving forward with Thunkable. ❤

Thanks to you too!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 12, 2022, 5:52am UTC](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235/26 "2022-05-12T05:52:36Z")

</div>

> [@paulovaz72](#):
>
> YOU ARE AMAZING!!! You did it! 🤓

Thank you @paulovaz72

> [@manyone](#):
>
> totally agree! thank you, @muneer !

Thank you @manyone

> [@manyone](#):
>
> (using object properties and testing for ‘[object Object]’! CLEVER!)

I was trying to find a replacement of **JavaScript typeof** property.

> [@paulovaz72](#):
>
> simple trick to discover if the object is a bucket or a simple value (no nested objects below)

I started to convert the object to JSON and count the number of **colons** in the JSON. Only a terminal node will contain a single colon, other nodes (buckets) will always have more than one colon.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [August 10, 2022, 5:53am UTC](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235/27 "2022-08-10T05:53:10Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

[Previous page](https://community.thunkable.com/t/recursive-function-to-look-up-multiple-occurrences-of-data-in-a-firebase-json-structure/1870235.md?page=1)
