简体   繁体   中英

Firestore Security Rules for Query with IN

I am doing a query

firestore().collection('stories')
        .where('published', '==', true)
        .where(firestore.FieldPath.documentId(), 'in', storyIds)
        .get()

I have a rule for stories

match /stories/{storyId} {
      allow read: if resource.data.published == true;
}

And getting an error [firestore/permission-denied] if there is id of unpublished story in my list. What am i doing wrong?

UPDATED

storyIds=["story2","story3"]

Firestore Docs

Story2 故事2文档

Story3 故事3文档

I've found solution. Just added my documentId in document as id and changed query.

firestore().collection('stories')
        .where('published', '==', true)
        .where('id', 'in', storyIds)
        .get()

This works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM