Henry
Henry

Reputation: 32915

How to write security rule for firestore with "A map of values" query?

Using the "A map of values" query method documented in https://firebase.google.com/docs/firestore/solutions/arrays

If I have this:

db.collection('posts')
  .where(`editorUids.${currentUser.uid}`, '==', true)

How would the security rule look like for restricting posts collection to only allow list if editorUids.x == true, where x is request.auth.uid?

Upvotes: 0

Views: 529

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317948

match /posts/{post} {
  allow list: if resource.data[request.auth.uid] == true;
}

Upvotes: 2

Related Questions