My app allows users to make a post
. From this post, any user can make a request
.
I want to make a function where the owner of the post can update a field in all the requests made to his/her post
, Let's say 'canceled' or 'delete' for example.
The picture below might help explain what I meant
The user 'A' accesses his/her posts Main collection
. Then there is a button that says CANCEL.
On the click of this button firebase
should check if there is a request sent to this post in the Sub-collection
. If there is a request, then a field, say 'Post-Status', in all the requests made to this post should be updated.
I know this code is wrong but this is the best I could come up with.
// inside the TextButton
FirebaseFirestore.instance.collection('main-collection name').doc(current-user-id).collection('sub-collection name').doc("I don't know what to put here").set({"Post-Status": "Canceled"}).
N/B: when I tried the code below, without putting anyting in the doc() for the subcollection, it creates a whole new collection in the sub-collection
FirebaseFirestore.instance.collection('main-collection name').doc(current-user-id).collection('sub-collection name').doc().set({"Post-Status": "Canceled"}).