RealtimeDB help needed

Hello, and thank you!

I am using this 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

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

blocks i use to update the DB

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.


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

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 .

@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.

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

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

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


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 ?!

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,

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

Try this,

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

@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?

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 .

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!

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!

1 Like

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

1 Like