I wanted to use dynamic paths selected by the user in my app to access/write data to my db. Sort of like a file path that the user can type, Eg: "users/mike/age". Using this string, I need to fetch as well as write data to the path in the db. Is there any way this is possible??
2
Answers
Firebase works in a way like
You can create a
Document
&Collection
dynamically in firebase, But you can not fetch any collection if are not known the name ofCollection
.It means if there is a
List of Documents
in aCollection
you can fetch the list by using its parent collection name but aList of Collection
nested under a Document can not be fetched unless you are known to names.For Example,
if there is a path
users/mike/age
. You can fetchusers
because you know that you created aCollection
namedusers
and all of its Documents likemike
can also be fetched. But if you have not known the age of user. You cannot fetch it.Kind of strange, but you could split the string then refactor with firebase path.