Gabriel
Nov 6, 2022

--

Hi Samantha,

Prior to writing a subcollection/nested collection. You first need to update the rules permission rules in Firebase. For example if you want to allow writing and reading to all nested collections, in my example, you would need to change:

match /r-test/{data} {

allow read, write, update, delete: if request.auth.uid != null;

}

To:

match /r-test/{data=**} {

allow read, write, update, delete: if request.auth.uid != null;

}

Once you have done that, in R you can use the same functions to write/read data into subcollection with commands such as:

write.db("projects/r-firestore-example/databases/(default)/documents/r-test/gabriel1/collection2", data, my_auth_info$idToken)

Where we are writing the the "collection2" which is inside the "r-test/gabriel1" document.

Hope this helps

--

--

Responses (1)