I have two array in firebase realtime database that will manage user followers and following. I've created this function in my vue app that will add the follow if an user click on the button in the profile of another user and the following into the profile of the user who clicked:
async followUser() {
await update(ref(db, 'Users/'+ this.profileKey), {
followers: [store.currentUser.uid]
})
await update(ref(db, 'Users/'+ store.currentUserKey), {
following: [this.$route.params.uid]
})
}
At the moment I've tested on two profile I've created ad-hoc and the function act as expected but I have a doubt about it. If the user will start follow other users, will the new entries will be added correctly into the existing array or all the data will be overwritten? What's the correct way to push or remove valuse into an array stored in firebase realtime database?