I can't figure out how to solve this issue with firebase : I have users, each user has posts, each post has an id generated by firebase, how can I store these ids in a user node ?
I'm using string,concatenating them, parsing them in my js app. Basically treating them as a csv file. But i guess that's a very ugly solution
What would be the way to store this kind of data ?
Edit:
UserID :
- Username = "User Name"
- Posts = "id1,id2,id3,id4"
When a user has a new post, I use a transaction to append a new id at the end of the string. When I need to delete an id, again I use a transaction and I delete the element using this code:
removeElem(list, value) {
var separator = ",";
var values = list.split(separator);
for (var i = 0; i < values.length; i++) {
if (values[i] == value) {
values.splice(i, 1);
return values.join(separator);
}
}
return list;
},