A. Ilazi A. Ilazi - 1 year ago 100
Javascript Question

Firebase: How to update arrays length when manually delete one path?

On my website a user can enter multiple addresses. The file structure looks like this:

enter image description here

I load the data to the users profile so that he can change it and add different cities if needed. To do that I loop through each address in a for-loop. For that purpose I need the correct length of address. But since address is an array after deleting one address the length still stays at two.

What options do I have?

Thank you

Answer Source

You should use Push method of Firebase instead of saving data in arrays

var ref=firebase.databae().ref("user/"+uid+"/address");

Firebase Save Data

Why to avoid arrays,please check Best Practice for Arrays

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download