0

One user gives a book to another. I want to write books into a definite table 'Borrowed books'. How must I change the rules? For now I've got an exeption: W/Firestore(21240):[Firestore]: Write failed at Borrowed books/books: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}

CollectionReference borrowedBooksTable =
FirebaseFirestore.instance.collection('Borrowed books');

final borrowedBooksReference =
borrowedBooksTable.doc('books');
await borrowedBooksReference.set(borrowedBook.toJson());
Evgen
  • 77
  • 6
  • Does this answer your question? [firestore: PERMISSION\_DENIED: Missing or insufficient permissions](https://stackoverflow.com/questions/46590155/firestore-permission-denied-missing-or-insufficient-permissions) – activout.se Jul 20 '22 at 19:55
  • Of course, it does not – Evgen Jul 21 '22 at 08:01

1 Answers1

1

By first enabling all reads and writes to that collection, you can examine how modifying security rules impacts this issue, as follows:

rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /yourCollectionName/{ID}{ allow read, write: if true; } } }

and then limit the collection as necessary.

To make the necessary adjustments and implement best practices, consult get started and rules structures recommendations.

Also, you can review the answer posted for a similar question in Stackoverflow.

As a suggestion, take a look at this link explaining more about the issue.