Skip to content

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

Merged
merged 7 commits into from
Jan 21, 2022
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2021

⚠️ No Changeset found

Latest commit: 586a952

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 29, 2021

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (4bd3a88)Merge (e0cfbaa)Diff
    browser228 kB228 kB+734 B (+0.3%)
    esm5285 kB285 kB+769 B (+0.3%)
    main453 kB454 kB+1.15 kB (+0.3%)
    module228 kB228 kB+734 B (+0.3%)
    react-native228 kB229 kB+734 B (+0.3%)
  • firebase

    TypeBase (4bd3a88)Merge (e0cfbaa)Diff
    firebase-auth-cordova.js91 B462 kB+462 kB (+508048.4%)
    firebase-auth-react-native.js101 B484 kB+484 kB (+479364.4%)
    firebase-firestore.js770 kB772 kB+2.18 kB (+0.3%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/H55IfFx1f5.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 29, 2021

Size Analysis Report 1

Affected Products

  • @firebase/firestore

    • _setIndexConfiguration

      Size

      TypeBase (4bd3a88)Merge (e0cfbaa)Diff
      size?20.7 kB? (?)
      size-with-ext-deps?69.2 kB? (?)

      Dependency

      TypeBase (4bd3a88)Merge (e0cfbaa)Diff
      functions?

      18 dependencies

      B
      Ea
      Fo
      L
      M
      Mh
      O
      Oh
      Su
      Ta
      U
      Ua
      Vu
      Zs
      ga
      qa
      st
      to

      ?
      classes?

      24 dependencies

      $h
      Aa
      C
      Fa
      G
      Gc
      J
      Mo
      Q
      Ra
      W
      X
      Y
      Z
      da
      dt
      it
      mt
      no
      tt
      tu
      wa
      xa
      z

      ?
      variables?

      D
      N
      _a
      _n
      _t
      j
      k
      vu
      wn

      ?
      enums??

      External Dependency

      ModuleBase (4bd3a88)Merge (e0cfbaa)Diff
      @firebase/app?

      SDK_VERSION
      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/logger?

      LogLevel
      Logger

      ?
      @firebase/util?

      FirebaseError

      ?

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/K5rRg4bA2l.html

Copy link

@thebrianchen thebrianchen left a 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. */

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

Copy link
Contributor Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/exception/error

Copy link
Contributor Author

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.

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.

Copy link
Contributor Author

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') {

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.

Copy link
Contributor Author

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.

@github-actions
Copy link
Contributor

Changeset File Check ⚠️

  • Changeset formatting error in following file:
    Some packages have been changed but no changesets were found. Run `changeset add` to resolve this error.
    If this change doesn't need a release, run `changeset add --empty`.
    

@schmidt-sebastian schmidt-sebastian merged commit 2d04af9 into master Jan 21, 2022
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/configureindexes branch January 21, 2022 20:24
@firebase firebase locked and limited conversation to collaborators Feb 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants