Firestore Security Rules - How can I check that a field is/isn't being modified?

前端 未结 9 614
孤城傲影
孤城傲影 2020-11-29 07:24

For the life of me, I cannot understand why the following is resulting in a false for allowing writes. Assume my users collection is empty to start

9条回答
  •  暖寄归人
    2020-11-29 07:57

    I solved it by using writeFields. Please try this rule.

    allow write: if !('role' in request.writeFields);
    

    In my case, I use list to restrict updating fields. It works, too.

    allow update: if !(['leader', '_created'] in request.writeFields);
    

提交回复
热议问题