-
Notifications
You must be signed in to change notification settings - Fork 946
Add setIndexConfiguration API #5843
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
Conversation
|
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
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 with some suggestions
readonly indexId: number, | ||
/** The collection ID this index applies to. */ | ||
readonly collectionGroup: string, | ||
/** Returns all field segments for this index. */ |
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.
nit: no need for returns
since not a method
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.
Done
* | ||
* The method accepts the JSON format exported by the Firebase CLI (`firebase | ||
* firestore:indexes`). If the JSON format is invalid, this method throws an | ||
* exception. |
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.
nit: s/exception/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.
Done
* Indexes are only supported with IndexedDb persistence. Invoke either | ||
* `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()` | ||
* before setting an index configuration. If IndexedDb is not enabled, any | ||
* index configuration is ignored. |
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.
What happens if the user sets index config without persistence enabled, then enables persistence afterwards? The current implementation still persists the index configs, but I think it'd be helpful to clarify what 'ignored' means in the documentation.
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.
This is not possible - setIndexConfiguration() requires an initialized client and persistence cannot be enabled afterwards.
fieldPathString | ||
); | ||
|
||
if (field.arrayConfig === 'CONTAINS') { |
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.
Should we consider validating that only one of arrayConfig
or order
is set and throw an error if both are set / include test for 'CONTAINS'?
The Android SDK doesn't validate, but we also don't allow directly setting indexes with key-value pairs there.
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 feel there are lots of ways we can validate here, and it is a bit of a rabbit hole that I don't want to go down just yet. If there is demand, then we can consider.
Changeset File Check
|
Ports https://github.com/firebase/firebase-android-sdk/blob/master/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java#L307
Index API is not exported to the main
index.ts
file and is hence still invisible.