-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exclude fields from getting indexed by datastore #16
Conversation
Codecov Report
@@ Coverage Diff @@
## master #16 +/- ##
==========================================
- Coverage 97.35% 93.19% -4.17%
==========================================
Files 1 1
Lines 227 235 +8
==========================================
- Hits 221 219 -2
- Misses 3 11 +8
- Partials 3 5 +2
|
var excludeIndex string | ||
// use the Extension name is passed else derive it dynamically | ||
if excludeFromIndexName != nil && len(excludeFromIndexName) > 0 { | ||
excludeFromIndexExt = fmt.Sprintf("[%s]:true ", excludeFromIndexName[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting way to find an extension, works for me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
…ame for excludig indexing of fields
@@ -18,21 +19,48 @@ import ( | |||
) | |||
|
|||
// ProtoMessageToDatastoreEntity will generate an Entity Protobuf that datastore understands | |||
func ProtoMessageToDatastoreEntity(src proto.Message, snakeCase bool, excludeFromIndex []string) (entity datastore.Entity, err error) { | |||
func ProtoMessageToDatastoreEntity(src proto.Message, snakeCase bool, excludeFromIndexName ...string) (entity datastore.Entity, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda missed that earlier, for explicitness sake, it wouldn't hurt if this argument is called excludeFromIndexOptionName
or similar to make it clear that this expects extension option name.
This release adds support for excluding the fields from being indexed by google cloud datastore using a custom extension
in proto files.
Please note that
exclude only works with one extension