FirebaseExtended / protobuf-rules-gen

This is an experimental protoc plugin that generates Firebase Rules for Cloud Firestore based on Google's Protocol Buffer format. This allows you to easily validate your data in a platform independent manner.
Apache License 2.0
197 stars 13 forks source link

nullable fields #24

Closed ribrdb closed 5 years ago

ribrdb commented 6 years ago

Our javascript code is setting optional fields to null instead of deleting them. This fails the type checks this project generates.

ribrdb commented 5 years ago

After thinking about this some more, it seems like this could be an important case to support. For example if I want to query for all Books that have no Author. I can query for 'Author == null', but not for 'Author property does not exist'.

rockwotj commented 5 years ago

It is an important use case, and I want to add it.

What do you think is the best way to enable this? Per field? That could be a bit verbose:

message Book {
  string author = 1 [(google.firebase.rules.firebase_rules_field).nullable = true];
}

or maybe:

message Book {
   [(google.firebase.rules.firebase_rules_message).nullable_fields = true]; // For all fields
  string author = 1;
}

WDYT?

ribrdb commented 5 years ago

Those both look good. Any reason to not support both?

rockwotj commented 5 years ago

Both is fine.

rockwotj commented 5 years ago

This is implemented however, since it's been moved to a new org, I don't have permissions to push anymore, once I get this resolved I'll open a PR.