Skip to content
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

feat(firebase_firestore): v1 rework #2913

Merged
merged 1 commit into from
Jul 7, 2020
Merged

feat(firebase_firestore): v1 rework #2913

merged 1 commit into from
Jul 7, 2020

Conversation

Salakar
Copy link
Member

@Salakar Salakar commented Jul 7, 2020


Co-authored-by: @Ehesp
Co-authored-by: @greghesp
Co-authored-by: @helenaford
Co-authored-by: @kirstywilliams
Co-authored-by: @Salakar


Description

As part of our on-going work for #2582 this is our finalised Firebase Firestore rework changes.

Firestore changes

Along with the below changes, the plugin has undergone a quality of life update which includes:

  • Better exceptions. Any Firestore specific errors now return a FirebaseException, allowing you to directly access the code (e.g. permission-denied) and message.
  • Improved stability. 100s of new tests (including e2e tests) have been added.
  • Helping developers get started. We've created a dedicated documentation website which covers many 'using Firestore in Flutter' topics (which we'll continue to expand on).

Firestore:

  • BREAKING: settings() is now a synchronous setter that accepts a Settings instance.
    • NEW: This change allows us to support changing Firestore settings (such as using the Firestore emulator) without having to quit the application, e.g. Hot Restarts.
  • BREAKING: enablePersistence() is now a Web only method, use [Settings.persistenceEnabled] instead for other platforms.
    • This change is to allow future support of Web enablePersistence being configurable with custom Web specific [PersistenceSettings] options.
  • DEPRECATED: Calling document() is deprecated in favor of doc().
  • DEPRECATED: Class Firestore is now deprecated. Use FirebaseFirestore instead.
  • DEPRECATED: Calling Firestore(app: app) is now deprecated. Use FirebaseFirestore.instance or FirebaseFirestore.instanceFor(app: app) instead.
  • NEW: Added clearPersistence() support.
  • NEW: Added disableNetwork() support.
  • NEW: Added enableNetwork() support.
  • NEW: Added snapshotInSync() listener support.
  • NEW: Added terminate() support.
  • NEW: Added waitForPendingWrites() support.
  • FIX: All document/query listeners & currently in progress transactions are now correctly torn down between Hot Restarts.

CollectionReference:

  • BREAKING: Getting a collection parent document via parent() has been changed to a getter parent.
  • DEPRECATED: Calling document() is deprecated in favor of doc().

Query:

  • BREAKING: The internal query logic has been overhauled to better assert invalid queries locally.
  • DEPRECATED: Calling getDocuments() is deprecated in favor of get().
  • BREAKING: getDocuments/get has been updated to accept an instance of GetOptions (see below).
  • NEW: Query methods can now be chained.
  • NEW: It is now possible to call same-point cursor based queries without throwing (e.g. calling endAt() and then endBefore() will replace the "end" cursor query with the endBefore).
  • NEW: Added support for the limitToLast query modifier.

QuerySnapshot:

  • DEPRECATED: documents has been deprecated in favor of docs.
  • DEPRECATED: documentChanges has been deprecated in favor of docChanges.

DocumentReference:

  • BREAKING/NEW: setData/set has been updated to accept an instance of SetOptions (see below, supports mergeFields).
  • BREAKING/NEW: get() has been updated to accept an instance of GetOptions (see below).
  • BREAKING: Getting a document parent collection via parent() has been changed to a getter parent.
  • DEPRECATED: documentID has been deprecated in favor of id.
  • DEPRECATED: setData() has been deprecated in favor of set().
  • DEPRECATED: updateData() has been deprecated in favor of update().

DocumentChange:

  • DEPRECATED: Calling document() is deprecated in favor of doc().

DocumentSnapshot:

  • BREAKING: The get data getter is now a data() method instead.
  • DEPRECATED: documentID has been deprecated in favor of id.
  • NEW: Added support for fetching nested snapshot data via the get() method. If no data exists at the given path, a StateError will be thrown.
  • FIX: NaN values stored in your Firestore instance are now correctly parsed when reading & writing data.
  • FIX: INFINITY values stored in your Firestore instance are now correctly parsed when reading & writing data.
  • FIX: -INFINITY values stored in your Firestore instance are now correctly parsed when reading & writing data.

WriteBatch:

  • DEPRECATED: setData() has been deprecated in favor of set().
  • DEPRECATED: updateData() has been deprecated in favor of update().
  • BREAKING: setData/set now supports SetOptions to merge data/fields (previously this accepted a Map).

Transaction:

  • BREAKING: Transactions have been overhauled to address a number of critical issues:
    • Values returned from the transaction will now be returned from the Future. Previously, only JSON serializable values were supported. It is now possible to return any value from your transaction handler, e.g. a DocumentSnapshot.
    • When manually throwing an exception, the context was lost and a generic PlatformException was thrown. You can now throw & catch on any exceptions.
    • The modify methods on a transaction (set, delete, update) were previously Futures. These have been updated to better reflect how transactions should behave - they are now synchronous and are executed atomically once the transaction handler block has finished executing.
  • FIX: Timeouts will now function correctly.
  • FIX: iOS: transaction completion block incorrectly resolving a FlutterResult multiple times.

See the new transactions documentation to learn more.

FieldPath:

  • NEW: The constructor has now been made public to accept a List of String values. Previously field paths were accessible only via a dot-notated string path. This meant attempting to access a field in a document with a . in the name (e.g. [email protected]) was impossible.

GetOptions: New class created to support how data is fetched from Firestore (server, cache, serverAndCache).

SetOptions: New class created to both merge and mergeFields when setting data on documents.

GeoPoint:

  • BREAKING: Add latitude and longitude validation when constructing a new GeoPoint instance.

Updated Example App

This PR also includes a new reworked example app that works on all platforms;

image
image


Related Issues

Related PRs

Co-authored-by: ehesp <[email protected]>
Co-authored-by: Helena Ford <[email protected]>
Co-authored-by: Kirsty Williams <[email protected]>
Co-authored-by: Greg Hesp <[email protected]>
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to determine that you authored the commits in this PR. Maybe you used a different email address in the git commits than was used to sign the CLA? If someone else authored these commits, then please add them to this pull request and have them confirm that they're okay with them being contributed to Google. If there are co-authors, make sure they're formatted properly.

In order to pass this check, please resolve this problem and then comment@googlebot I fixed it... If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@Salakar
Copy link
Member Author

Salakar commented Jul 7, 2020

@googlebot I fixed it.

@Salakar Salakar changed the title feat(firebase_firestore): v1 rework (#28) feat(firebase_firestore): v1 rework Jul 7, 2020
@greghesp
Copy link
Contributor

greghesp commented Jul 7, 2020

@googlebot I fixed it.

1 similar comment
@Salakar
Copy link
Member Author

Salakar commented Jul 7, 2020

@googlebot I fixed it.

@Salakar Salakar added cla: yes and removed cla: no labels Jul 7, 2020
@googlebot
Copy link

☹️ Sorry, but only Googlers may change the label cla: yes.

@googlebot googlebot removed the cla: yes label Jul 7, 2020
@Salakar
Copy link
Member Author

Salakar commented Jul 7, 2020

Will admin merge after GH actions pass, ignoring CLA status issues for now as Invertase has a corporate CLA that covers this anyway:

image

This was referenced Jul 9, 2020
@shinriyo
Copy link
Contributor

@Salakar Thank you very much!

@eli-front
Copy link

Is this implemented into the current cloud_firestore version?

@shinriyo
Copy link
Contributor

not released? yet?

@formvoltron
Copy link

formvoltron commented Jul 11, 2020

Maybe a week ago I started to get these types of errors when trying to access firebase from flutter.

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: PlatformException(Error 7, FIRFirestoreErrorDomain,
false for ‘list’ @ L14)

I have tried:

  • reverted to flutter stable channel (had been experimenting with web flutter in beta channel)
  • removed generated_plugin_registrant file which is only for web version
  • did flutter clean & went into ios folder to remove DerivedData and Podfile.lock

I still get these errors. I'm not sure what else I can do.

Are these changes in this pull request possibly the culprit?

@Salakar
Copy link
Member Author

Salakar commented Jul 13, 2020

@eli-front @shinriyo @formvoltron - these changes have not been released yet.

@eli-front
Copy link

eli-front commented Jul 13, 2020

Thanks @Salakar

Any idea when this will be released?

I also found this earlier today and it seems very similar: #84

@formvoltron
Copy link

formvoltron commented Jul 14, 2020 via email

@najibghadri
Copy link

Hello, when can we expect the release? I am very excited for the composite where query.

@Salakar
Copy link
Member Author

Salakar commented Jul 15, 2020

@firebase firebase locked as resolved and limited conversation to collaborators Jul 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants