Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Firestore security rules: how to check if property exists?

I need to check is property exists in document in store. allow update, delete: if resource.data.uid; in code above i have error "Property uid is undefined on object.", so how i can check is uid in data?

like image 845
A. Melnyk Avatar asked Dec 22 '22 22:12

A. Melnyk


1 Answers

To check if the document contains a specific field, I use in:

allow update, delete: if 'uid' in resource.data;
like image 198
Frank van Puffelen Avatar answered Apr 18 '23 11:04

Frank van Puffelen