# RealtimeDB help needed

**URL:** <https://community.thunkable.com/t/realtimedb-help-needed/465176>\
**Category:** Questions about Thunkable X\
**Created:** [February 14, 2020, 5:30pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176 "2020-02-14T17:30:10Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 14, 2020, 5:30pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/1 "2020-02-14T17:30:10Z")

</div>

Hello, and thank you!

I am using [this](http://community.thunkable.com/t/one-way-to-parse-a-realtimedb-response/464889) method to parse a realtimeDB response.

It produces my 50 value list. I can initialze this list no issue. I do that when my splashscreen displays like htis

 ![Screen Shot 2020-02-14 at 12.13.45 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/0/e0978c4cc3cacd2d172466d55b268b9280908f82.png)

I am then later trying to update the RealtimeDB after a value change in the app (this takes place on a different screen) with these blocks,

now i have 2 issues. when i add the listener, the performance of the app really dips (@Mark, i know you’ve asked abotu these types of performance issues)

issue two, when i use these blocks to overwrite the previous realtimeDB list due to a change in the mirror stored variable (i.e. a user takes data), the app sends a single value only and this overwrites everything in the notes bucket with that single value instead of rewriting all values stored in “allproblembehaivorcounts”

DB before i use the following blocks

 ![Screen Shot 2020-02-14 at 12.18.33 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/d/6dedff01449ca0d1ac724aabfacf1a317b718b10.png)

blocks i use to update the DB

 ![Screen Shot 2020-02-14 at 12.15.05 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/e/9e1633498a280ab58e6ed636b73fbdabe1c3d2ca.png)

DB after i use these blocks. In this example, I changed the value of the the item at index 0 in ‘stored variable allproblembehaviors’ via a button push in app.

 ![Screen Shot 2020-02-14 at 12.18.39 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/f/6fb6d45de5e7e11b56b5e180a216ddbedf5a27f5.png)  
can anybody suggest a fix for the second issue?

as you can see above, after changing data in the app, all but the first indexed value were deleted

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [February 14, 2020, 7:06pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/2 "2020-02-14T19:06:49Z")

</div>

The problem is that you are changing only one item a time then update the whole node of the DB data which has only one child what makes the node to be having only the last updated item .  
I think you can fix this problem using Object has the whole childs and update the whole node of your DB .

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 14, 2020, 7:16pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/3 "2020-02-14T19:16:06Z")

</div>

@davidsobhysabetb, thank you for your response! could you show a block example of what you mean?

Let me clarify for what stated above. Maybe i’m misunderstanding what you are saying. When I change the value of 1 item in that list in the app, I change it in the variable ‘stored allProblemBehaivorCounts’ first and then i save that variable to firebase. My thought is that even though i change 1 item in the list, it should still save the whole list to firebase.

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [February 14, 2020, 7:22pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/4 "2020-02-14T19:22:50Z")

</div>

Ok, let me first ask you, how would you decide which child index of email node to be updated ?

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 14, 2020, 7:28pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/5 "2020-02-14T19:28:53Z")

</div>

> [@davidsobhysabetb](#):
>
> which child index of email nod

Well, I’m not sure. Probably the same way as when I alter the value in the on phone stored variable.

![Screen Shot 2020-02-14 at 2.16.25 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/optimized/3X/5/4/54e1fe8270429da4c2be21f05cc67aa2ccf0144d_2_690x37.png)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 14, 2020, 7:30pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/6 "2020-02-14T19:30:16Z")

</div>

but what i’ve been ding is trying to first change that index value and then save the entire “stored allProblemBehaivorCounts” to the DB

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [February 14, 2020, 7:35pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/7 "2020-02-14T19:35:36Z")

</div>

![Screen Shot 2020-02-14 at 12.15.05 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/1/f129b5320d2be1336d9c994fe7f3c5bd8bf861bc.png)  
what is that for ? do you notice that the sum of this should be an index of the list ? or you just want to add the elements of that list to the left one ?!

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 14, 2020, 7:42pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/8 "2020-02-14T19:42:38Z")

</div>

yeah. so, it’s kinda complicated. it’s like a classroom beahivor tracker.

there are 5 behaivor s lots for each of the 10 students. i only display 1 data sheet with dynamic content like slider rows, button rows, switch rows, text entry ros. and all are based on settings like which studnet, how many beahviors, what type of format for data recording

so,

 ![Screen Shot 2020-02-14 at 2.27.04 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/5/c5169e4b03e3122759e5461b295cdc1aeaccabf7.png)

so the red circle gets the 1st position of all 5 possible behavior slots based on the student, and then the green circle moves the postion forward to the appropriate child behaivor. so for examle. if i am child 2. in the list i’m number 2-1\*5 which means i will start at the 5th index. then i get the index for which slider the measure came from. this lets me know which behaivor slot was altered. i then add that to the first index (5) and this lets me know which index out of the 50 i want to change.

Are you suggesting that because of where I have the blocks to save to the database, being below blocks that I was changing a specific value in in that variable, that maybe that’s why it saving that specific indexed value only to the database when I do save?

(((Index of current child in child name list) - 1)\*5)+(index of component from component list)

This is how I find the index of the value I want to change in the variable stored allProvlemBehavioraCounts

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [February 14, 2020, 8:17pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/9 "2020-02-14T20:17:58Z")

</div>

Try this,

 ![Screen Shot 2020-02-14 at 12.15.05 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/d/cd5c0f3ffe4dc6f3e3f84adec5ef46b4f3ea9ee8.png)

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [February 14, 2020, 8:19pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/10 "2020-02-14T20:19:01Z")

</div>

You can just join your list index with scores/ node and save the new value

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 14, 2020, 9:52pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/11 "2020-02-14T21:52:18Z")

</div>

@davidsobhysabetb thanks for your suggestion. I’ll try this later on today! To verify, it looks as if, I get the index of the number I want to change from the stored variable with those 50 values. Then on the save Black for the database, I join that index number at the end of the key? Wouldn’t that create another level? I like that idea, but I think it would make managing a change in the dB

Then I put a listener on the username key? Would that return a value anytime any value is changed in a sub node

Key: notes/username/index?

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [February 15, 2020, 12:05am UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/12 "2020-02-15T00:05:13Z")

</div>

> Wouldn’t that create another level?

Another level of what ?  
If you add the whole node as listener, then any change in any child will return you a value .

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 15, 2020, 4:56am UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/13 "2020-02-15T04:56:24Z")

</div>

I think this will work.

I will report back, so far so good. Now i need to parse out the response!

I think you got me onto something here!

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 15, 2020, 5:42am UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/14 "2020-02-15T05:42:43Z")

</div>

Thank you @davidsobhysabetb

this worked!! Now i plan to make it more complex!

currently, scores are synced across devices. but, recording format needs to be the same as well as child and behavior names. I plan to apply this same idea with all of those. I will shaare my app in a couple weeks when it has those imlemented fully! I am really excited. Being able to do things colaboratively really adds to the value of an app!

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [February 15, 2020, 12:18pm UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/15 "2020-02-15T12:18:49Z")

</div>

Happy to know that !  
good luck with your great project @jared

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:41am UTC](https://community.thunkable.com/t/realtimedb-help-needed/465176/16 "2024-11-08T11:41:01Z")

</div>


