google_cloud_firestore 0.6.0
google_cloud_firestore: ^0.6.0 copied to clipboard
A Dart client library for Google Cloud Firestore, a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.
0.6.0 #
- Fixed a failed first read in
runTransaction()also being reported to the zone as an uncaught async error, once per attempt, alongside the error the caller receives. A transient error that the transaction recovered from on retry could still crash an isolate that treats uncaught errors as fatal. Applies toget,getAll,getQuery,getAggregateQueryandexecutePipelinein read-write and read-only transactions. - Fixed
Transaction.getAll()with an empty list failing a read-write transaction withaborted: Transaction max attempts exceededafter retrying. It now throws anArgumentErrorstraight away, likeFirestore.getAll()and the Node Admin SDK. - Spread more than 10 concurrent requests over multiple HTTP/2 connections: each connection now carries up to 10 streams instead of 100, and up to 10 idle connections stay open between bursts. This speeds up large parallel reads, which previously shared one connection. Nothing changes at 10 or fewer concurrent requests.
- Fixed
sumandaverageaggregations andfindNearest()vector queries built from alimitToLast()query running over the first documents instead of the last. They now send the same flipped ordering and cursors asQuery.get(), and vector query results are returned in the query's order, matching the Node Admin SDK. LikeQuery.get(), they now throw anArgumentErrorwhen thelimitToLast()query has noorderBy()clause instead of silently running the wrong query. - Fixed
limitToLast()queries returning documents in reverse order fromQuery.get(),Query.explain()andTransaction.getQuery(). Results anddocChangesnow follow the query'sorderBy, matching the Node Admin SDK. - Fixed Firestore requests running about 2× slower under concurrent load since 0.5.5.
package:http2advertised only a 64 KiB receive window, which every request on a pooled HTTP/2 connection shared;http23.2.0 raises it to 4 MiB per stream and 16 MiB per connection. Requireshttp2: ^3.2.0. - Fixed
Firestore.terminate()creating the auth client of a Firestore that never sent a request just to close it. Without Application Default Credentials this threwMetadataServerException, and a failed credential lookup left the HTTP/2 transport open. Requests made afterterminate()now throw aStateError(anError, not anException) instead of opening a new client. - Added
CollectionReference.listDocumentsPages(), which lists a collection's documents, including missing documents, oneDocumentReferencePageat a time. It takes an optionalpageSizeand apageTokento resume from a previous page'snextPageToken, so large collections can be walked without holding every reference in memory. - Fixed
CollectionReference.listDocuments()returning only the first page of results. It now followsnextPageTokenuntil the collection is exhausted, matching the Node Admin SDK, so large collections and missing documents past the first page are no longer silently dropped. - Fixed
DocumentReference.listCollections()andFirestore.listCollections()returning only the first page of collection IDs. They now follownextPageTokenuntil every collection has been returned. - Breaking:
PipelineFunctions.joinandPipelineFunctions.splitnow require their delimiter, matchingPipelineExpressionand the Node Admin SDK. A one-argument call was always rejected by the backend withINVALID_ARGUMENT. - Breaking:
PipelineFunctions.mapRemoveandPipelineExpression.mapRemovetake a single key (aStringor an expression) and sendmap_remove(map, key), like the Node Admin SDK, instead of anIterableof keys. Chain.mapRemove('a').mapRemove('b')to remove several keys. - Breaking:
PipelineResult.getnow resolves dot-separated paths such as'metadata.lang'as nested fields, likeDocumentSnapshot.get, and also accepts aFieldPath. A top-level field whose name contains a dot, whichget('a.b')used to return, is now read withget(FieldPath(['a.b'])). A string that is empty, starts or ends with., or contains..or any of*~/[]now throws anArgumentErrorinstead of returningnull. - Breaking:
PipelineFunctions.arrayTransformno longer takes a trailing index alias. Use the newPipelineFunctions.arrayTransformWithIndex(array, elementAlias, indexAlias, transform), which matchesPipelineExpression.arrayTransformWithIndexand the Node Admin SDK and sends the samearray_transformfunction. - Fixed
PipelineFunctions.arrayMaximum,arrayMaximumN,arrayMinimum,arrayMinimumNandarraySumsending function names (array_maximum, ...) that the backend rejects. They now sendmaximum,maximum_n,minimum,minimum_nandsum, like theirPipelineExpressioncounterparts. - Fixed
Pipeline.addFieldssending onealiasfunction per field instead of a single map keyed by alias, which the backend rejected. - Fixed
PipelineSource.collectionGroup(), andcreateFrom()on a collection group query, omitting the leading root ancestor argument of thecollection_groupstage. - Fixed
PipelineValueType.doublesending'double'instead of'float64', which madeisTypefail. Added theint32,decimal128,maxKey,minKey,objectIdandregexvalue types. - Fixed
cosineDistance,dotProduct,euclideanDistanceandPipeline.findNearestsending a plain list of numbers as an array instead of a vector. - Fixed Pipeline functions such as
equalAny,notEqualAny,arrayContainsAll,arrayContainsAnyandmapMergefailing when aListorMapargument holds expressions. Collection arguments are now sent asarray(...)/map(...)functions, like the Node Admin SDK, and the static and fluent forms encode identically. - Fixed the top-level
ascending()anddescending()sorting by a string constant when given a field name. AStringnow names a field, like everywhere else in the Pipeline API and in the Node Admin SDK. Pipeline.select,addFields,aggregateanddistinctnow throw anArgumentErroron a duplicate field name or alias instead of silently keeping the last one, like the Node Admin SDK.PipelineExpression.substringandsubstringLiteralnow take(position, [length])likePipelineFunctions.substring: the second argument is a length, not an end index, and can be omitted.PipelineExpression.roundnow accepts the optionaldecimalPlacesargument.- Exported the top-level
variable()Pipeline helper. - Every Pipeline function now has a single implementation shared by all of its forms. The fluent
PipelineExpressionmethod, the top-level helper (equal,and,not, ...) and theExpressionalias forward to thePipelineFunctionsfunction (andfield,constantandvariabletoExpression), so every form sends the same request. PipelineFunctions.arraySlicenow takes an optionallength, likePipelineExpression.arraySliceand the Node Admin SDK.PipelineFunctions.rawnow acceptsoptions, likeExpression.raw.PipelineExpression.arrayContainsAllandarrayContainsAnynow also accept an array expression, like theirPipelineFunctionsforms and the Node Admin SDK.- Fixed Pipeline field names that are not simple identifiers being sent unquoted. They are now backtick-quoted like the Node Admin SDK, so
field('first-name')sends`first-name`.field()andExpression.field()also accept aFieldPath.PipelineField.pathreturns the quoted path, andfield('')andfield('a..b')now throw. - Fixed
Pipeline.select,distinctand thegroupsofaggregatekeying aStringfield name that is not an identifier, such as'last name', by the raw string, which the backend rejects as an invalid property path. It is now keyed by its quoted path,`last name`, like aPipelineField, soselect(['x-y', field('x-y')])now throws for a duplicate key. An alias is still keyed as written, and must be a valid field path. - Pipeline stages and functions now accept a
FieldPathwherever they accept aStringfield name, asfield()does: the target of everyPipelineFunctionsfunction,ascending()anddescending(), the entries ofselect,distinct,aggregategroups andremoveFields,unnest,replaceWith, andfindNearest'svectorFieldanddistanceResultField. AFieldPaththere used to be sent as a constant, which failed to encode. - Fixed field paths containing a backtick being escaped as a lone backslash, which named a different field, in queries, field masks and Pipelines.
- Fixed
Pipeline.createFrom()andDocumentSnapshotquery cursors leaving!=andnot-infields out of the implicit ordering, and ordering inequality fields by their quoted names instead of segment by segment, unlike the backend and the Node Admin SDK. A snapshot cursor now needs a value for every inequality field. - Fixed
Pipeline.createFrom()of a query with a cursor on a descending ordering keeping the wrong side of the bound. - Fixed
Pipeline.createFrom()of aVectorQuerysending itsdistanceThresholdas an undocumentedfind_nearestoption. It is now applied as a filter on the distance. - Fixed
indexModebeing sent as anindex_modeoption the backend rejects; it is deprecated.Pipeline.execute()andTransaction.executePipeline()now ignoreindexMode, andPipelineIndexModeis deprecated too: its only value,recommended, is already the backend's default. - Fixed
Pipeline.findNearest(distanceThreshold:)sending adistance_thresholdoption, which the backend rejects. It now adds awherestage afterfind_nearestthat keeps the results within the threshold, asPipeline.createFrom()does for aVectorQuery. - Fixed Pipeline results failing to decode when a reference that names no document, such as the database root returned by
parent(), is nested in a map or array. It now decodes to its resource name at every depth, as it already did for top-level fields. - Pipeline raw options now match the Node Admin SDK. Every stage and source takes an optional
rawOptions. Keys inrawOptionsandrawStage(options:)are dot-separated paths merged into the typed options, and keys with an empty segment throw anArgumentError.rawStagesends collections nested in aMapargument asmap(...)/array(...)functions. PipelineFunctions.addandmultiplytake an optional trailing list of further operands, andPipelineExpression.addandmultiplytake(second, [others]), like the variadic Node Admin SDK functions. Further operands are sent as nested two-operand calls,add(add(a, b), c), since the backend'saddandmultiplytake exactly two operands.PipelineSource.documents()also accepts document paths such as'books/book1', validated likeFirestore.doc().PipelineFunctions.map()also accepts a DartMap, as inmap({'title': field('title')}).- Added the
PipelineOrdering.exprandPipelineOrdering.directiongetters.
0.5.5 #
- Fixed slow and failing requests under high concurrency by pooling shared HTTP/2 connections by default instead of opening a new HTTP/1.1 connection per request, via
package:http2'sHttp2Client. Credential endpoints that speak plain HTTP, such as the GCE/Cloud Run metadata server, keep using HTTP/1.1. - Widen dependency upper bounds for
google_cloud_firestore_v1(>=0.5.2 <0.7.0) andgoogle_cloud_rpc(>=0.5.2 <0.7.0). - Update
handleFirestoreExceptionto inspectServiceException.statusandServiceException.messagefor compatibility withgoogle_cloud_rpc 0.6.0.
0.5.4 #
- Added support for Firestore Pipelines:
Firestore.pipeline(), thePipelinestage builders, thePipelineFunctionsexpression catalog, and the top-levelequal,notEqual,lessThan,lessThanOrEqual,greaterThan,greaterThanOrEqual,and,or,not,field,constant,ascendinganddescendinghelpers. The expression surface mirrors the Node Admin SDK. - Added
PipelineSource.createFrom()to convert aQueryorVectorQueryinto an equivalent Pipeline. - Added
Transaction.executePipeline()to run a Pipeline at a transaction's snapshot, with the sameindexMode,explainandrawOptionsparameters asPipeline.execute(). - Added Pipeline execution options on
Pipeline.execute():indexMode,explainfor planner statistics (read back fromPipelineSnapshot.explainStats), and arawOptionsescape hatch for options this SDK does not wrap yet. PipelineFunctions.minimum()/maximum()are aggregate-only; uselogicalMinimum()/logicalMaximum()for the element-wise form.- Fixed
Settings.sslbeing ignored when connecting to a customSettings.hostendpoint withoutFIRESTORE_EMULATOR_HOST. - Fixed
FirestoreHttpClient.getProjectId()and_run()ignoringSettings.projectIdandSettings.credentialservice account project IDs whenGOOGLE_CLOUD_PROJECTis set in the ambient process environment.
0.5.3 #
- Added
Settings.headersto attach custom HTTP headers to every outgoing Firestore request. - Fixed intermittent
ClientException: Connection closed before full header was receivedon queries and aggregations under high concurrency; these now retry with backoff. - Fixed
Firestore.getAll()retrying transient errors indefinitely; it now retries a bounded number of times before surfacing the error. - Updated
Transaction.deleteandTransaction.updatetype constraints to acceptDocumentReference<Object?>. (thanks to @Levin-Me) - Made
Timestampencodable by addingtoJsonmethod. (thanks to @OutdatedGuy) - Update dependency
googleapis_auth: ^2.3.3to fixauth/insufficient-permissionerrors with Application Default Credentials that have no quota project set.
0.5.2 #
- Fixed
Firestore.projectIdnot readingGOOGLE_CLOUD_PROJECTwhen using Application Default Credentials locally. - Fixed
FieldMasknot available from export. (thanks to @OutdatedGuy) - Require
google_cloud: '>=0.4.0 <0.6.0'
0.5.1 #
- Added retry support for
WriteBatch.commit()on transient errors (ABORTED,UNAVAILABLE,RESOURCE_EXHAUSTED). - Added an example.
- Added a more detailed project description.
- Update dependency
meta: ^1.17.0to allow workspaces with stable Flutter.
0.5.0 #
- First release.