I appreciate any assistance in advance, as this issue has been causing me a lot of frustration!
Currently, I am adhering to the firestore data model where users are able to create their own documents associated with their userID. This ensures that users can only view and manage requests they have created. However, there is an administrator who needs access to and be able to edit requests submitted by these users.
Up until now, I have managed to access the subcollection using collectionGroup('subcollection'). While it does retrieve the documents, whenever I attempt to update or delete any document (other than those I have created myself as an admin), it throws an uncaught (in promise) FirebaseError: No document to update error.
HTML:
<!-- Add New Request -->
<input
type="submit"
@click="addRequest"
value="Save and Add"
/>
<!-- Update Past Request -->
<button
@click="updateRequest()"
type="button"
v-if="modal == 'edit'"
>Update
</button>
<!-- Delete Past Request -->
<button
@click="deleteRequest(request)"
type="button"
v-if="modal == 'edit'"
>Delete
</button>
<!-- Set return objects -->
data() {
return {
requests: [],
request: {
//Standard
req_assigned: null,
req_contact: null,
req_status: null,
timestamp: null
},
}
}
<!-- Firestore Assign -->
firestore() {
const user = fb.auth().currentUser;
return {
requests: db.collection("uzers").doc(user.uid).collection("requestz"),
uzers: db.collection("uzers").doc(user.uid),
bulksettings: db.collection("bulksettingz")
};
},
JAVASCRIPT:
// Add New Request
addRequest() {
this.$firestore.requests.add(this.request);
}
// Update Past Request
updateRequest() {
this.$firestore.requests.doc(this.request.id).update(this.request);
},
// Delete Past Request
deleteProduct(doc) {
this.$firestore.requests.doc(doc.id).delete();
},
THE ERROR:
index.cjs.js?e89a:350 Uncaught (in promise) FirebaseError: No document to update: projects/vue-shop-276c4/databases/(default)/documents/uzers/k0yZFhDbldVpf6FhhPMcykK5GJD3/requestz/9ET8nk53MxBx3JlhZqKx
at new FirestoreError (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:350:28)
In summary, I am facing challenges while trying to modify and remove requests created by other users. Any guidance on resolving this issue would be greatly appreciated.