@firebase/firestore 3.4.8-canary.7b58dabdf → 3.4.8-canary.9417675e6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/firestore/src/core/query.d.ts +2 -4
- package/dist/firestore/src/local/index_manager.d.ts +5 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/firestore/src/model/collections.d.ts +1 -1
- package/dist/firestore/src/util/misc.d.ts +3 -0
- package/dist/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/index.esm2017.js +2611 -2562
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2899 -2854
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +132 -54
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +132 -54
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +2679 -2630
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +5 -0
- package/dist/lite/firestore/src/core/query.d.ts +2 -4
- package/dist/lite/firestore/src/local/index_manager.d.ts +5 -0
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/lite/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/index.browser.esm2017.js +402 -406
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +380 -384
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +5 -7
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +5 -7
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1176 -1180
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +97 -97
- package/dist/lite/packages/firestore/src/core/query.d.ts +2 -4
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +5 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/packages/firestore/dist/index.esm2017.d.ts +168 -168
- package/dist/packages/firestore/src/core/query.d.ts +2 -4
- package/dist/packages/firestore/src/local/index_manager.d.ts +5 -0
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/private.d.ts +5 -0
- package/package.json +9 -9
package/dist/index.node.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import * as grpc from '@grpc/grpc-js';
|
|
|
8
8
|
import * as protoLoader from '@grpc/proto-loader';
|
|
9
9
|
|
|
10
10
|
const name = "@firebase/firestore";
|
|
11
|
-
const version$1 = "3.4.8-canary.
|
|
11
|
+
const version$1 = "3.4.8-canary.9417675e6";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -61,7 +61,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
61
61
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
62
62
|
User.MOCK_USER = new User('mock-user');
|
|
63
63
|
|
|
64
|
-
const version = "9.6.11-canary.
|
|
64
|
+
const version = "9.6.11-canary.9417675e6";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* @license
|
|
@@ -5714,7 +5714,7 @@ function asCollectionQueryAtPath(query, path) {
|
|
|
5714
5714
|
* Returns true if this query does not specify any query constraints that
|
|
5715
5715
|
* could remove results.
|
|
5716
5716
|
*/
|
|
5717
|
-
function
|
|
5717
|
+
function queryMatchesAllDocuments(query) {
|
|
5718
5718
|
return (query.filters.length === 0 &&
|
|
5719
5719
|
query.limit === null &&
|
|
5720
5720
|
query.startAt == null &&
|
|
@@ -5723,12 +5723,6 @@ function matchesAllDocuments(query) {
|
|
|
5723
5723
|
(query.explicitOrderBy.length === 1 &&
|
|
5724
5724
|
query.explicitOrderBy[0].field.isKeyField())));
|
|
5725
5725
|
}
|
|
5726
|
-
function hasLimitToFirst(query) {
|
|
5727
|
-
return !isNullOrUndefined(query.limit) && query.limitType === "F" /* First */;
|
|
5728
|
-
}
|
|
5729
|
-
function hasLimitToLast(query) {
|
|
5730
|
-
return !isNullOrUndefined(query.limit) && query.limitType === "L" /* Last */;
|
|
5731
|
-
}
|
|
5732
5726
|
function getFirstOrderByField(query) {
|
|
5733
5727
|
return query.explicitOrderBy.length > 0
|
|
5734
5728
|
? query.explicitOrderBy[0].field
|
|
@@ -6112,8 +6106,12 @@ function mutableDocumentMap() {
|
|
|
6112
6106
|
return EMPTY_MUTABLE_DOCUMENT_MAP;
|
|
6113
6107
|
}
|
|
6114
6108
|
const EMPTY_DOCUMENT_MAP = new SortedMap(DocumentKey.comparator);
|
|
6115
|
-
function documentMap() {
|
|
6116
|
-
|
|
6109
|
+
function documentMap(...docs) {
|
|
6110
|
+
let map = EMPTY_DOCUMENT_MAP;
|
|
6111
|
+
for (const doc of docs) {
|
|
6112
|
+
map = map.insert(doc.key, doc);
|
|
6113
|
+
}
|
|
6114
|
+
return map;
|
|
6117
6115
|
}
|
|
6118
6116
|
function newOverlayMap() {
|
|
6119
6117
|
return new ObjectMap(key => key.toString(), (l, r) => l.isEqual(r));
|
|
@@ -10018,6 +10016,9 @@ class MemoryIndexManager {
|
|
|
10018
10016
|
// Field indices are not supported with memory persistence.
|
|
10019
10017
|
return PersistencePromise.resolve(null);
|
|
10020
10018
|
}
|
|
10019
|
+
getMinOffset(transaction, target) {
|
|
10020
|
+
return PersistencePromise.resolve(IndexOffset.min());
|
|
10021
|
+
}
|
|
10021
10022
|
updateCollectionGroup(transaction, collectionGroup, offset) {
|
|
10022
10023
|
// Field indices are not supported with memory persistence.
|
|
10023
10024
|
return PersistencePromise.resolve();
|
|
@@ -10244,9 +10245,9 @@ class IndexedDbIndexManager {
|
|
|
10244
10245
|
const upperBound = upperBounds
|
|
10245
10246
|
? this.generateUpperBound(indexId, arrayValue, upperBounds[i % scansPerArrayElement], upperBoundInclusive)
|
|
10246
10247
|
: this.generateEmptyBound(indexId + 1);
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10248
|
+
const notInBound = notInValues.map(notIn => this.generateLowerBound(indexId, arrayValue, notIn,
|
|
10249
|
+
/* inclusive= */ true));
|
|
10250
|
+
indexRanges.push(...this.createRange(lowerBound, upperBound, notInBound));
|
|
10250
10251
|
}
|
|
10251
10252
|
return indexRanges;
|
|
10252
10253
|
}
|
|
@@ -10286,15 +10287,18 @@ class IndexedDbIndexManager {
|
|
|
10286
10287
|
});
|
|
10287
10288
|
}
|
|
10288
10289
|
getIndexType(transaction, target) {
|
|
10289
|
-
|
|
10290
|
-
return this.
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10290
|
+
let indexType = 2 /* FULL */;
|
|
10291
|
+
return PersistencePromise.forEach(this.getSubTargets(target), (target) => {
|
|
10292
|
+
return this.getFieldIndex(transaction, target).next(index => {
|
|
10293
|
+
if (!index) {
|
|
10294
|
+
indexType = 0 /* NONE */;
|
|
10295
|
+
}
|
|
10296
|
+
else if (indexType !== 0 /* NONE */ &&
|
|
10297
|
+
index.fields.length < targetGetSegmentCount(target)) {
|
|
10298
|
+
indexType = 1 /* PARTIAL */;
|
|
10299
|
+
}
|
|
10300
|
+
});
|
|
10301
|
+
}).next(() => indexType);
|
|
10298
10302
|
}
|
|
10299
10303
|
/**
|
|
10300
10304
|
* Returns the byte encoded form of the directional values in the field index.
|
|
@@ -10555,7 +10559,7 @@ class IndexedDbIndexManager {
|
|
|
10555
10559
|
* '[foo > 2 && foo != 3]` becomes `[foo > 2 && < 3, foo > 3]`.
|
|
10556
10560
|
*/
|
|
10557
10561
|
createRange(lower, upper, notInValues) {
|
|
10558
|
-
// The
|
|
10562
|
+
// The notIn values need to be sorted and unique so that we can return a
|
|
10559
10563
|
// sorted set of non-overlapping ranges.
|
|
10560
10564
|
notInValues = notInValues
|
|
10561
10565
|
.sort((l, r) => indexEntryComparator(l, r))
|
|
@@ -10601,6 +10605,20 @@ class IndexedDbIndexManager {
|
|
|
10601
10605
|
}
|
|
10602
10606
|
return ranges;
|
|
10603
10607
|
}
|
|
10608
|
+
getMinOffset(transaction, target) {
|
|
10609
|
+
let offset;
|
|
10610
|
+
return PersistencePromise.forEach(this.getSubTargets(target), (target) => {
|
|
10611
|
+
return this.getFieldIndex(transaction, target).next(index => {
|
|
10612
|
+
if (!index) {
|
|
10613
|
+
offset = IndexOffset.min();
|
|
10614
|
+
}
|
|
10615
|
+
else if (!offset ||
|
|
10616
|
+
indexOffsetComparator(index.indexState.offset, offset) < 0) {
|
|
10617
|
+
offset = index.indexState.offset;
|
|
10618
|
+
}
|
|
10619
|
+
});
|
|
10620
|
+
}).next(() => offset);
|
|
10621
|
+
}
|
|
10604
10622
|
}
|
|
10605
10623
|
/**
|
|
10606
10624
|
* Helper to get a typed SimpleDbStore for the collectionParents
|
|
@@ -13771,7 +13789,7 @@ class LocalStoreImpl {
|
|
|
13771
13789
|
this.mutationQueue = this.persistence.getMutationQueue(user, this.indexManager);
|
|
13772
13790
|
this.localDocuments = new LocalDocumentsView(this.remoteDocuments, this.mutationQueue, this.indexManager);
|
|
13773
13791
|
this.remoteDocuments.setIndexManager(this.indexManager);
|
|
13774
|
-
this.queryEngine.
|
|
13792
|
+
this.queryEngine.initialize(this.localDocuments, this.indexManager);
|
|
13775
13793
|
}
|
|
13776
13794
|
collectGarbage(garbageCollector) {
|
|
13777
13795
|
return this.persistence.runTransaction('Collect garbage', 'readwrite-primary', txn => garbageCollector.collect(txn, this.targetDataByTarget));
|
|
@@ -15513,10 +15531,30 @@ class MemoryEagerDelegate {
|
|
|
15513
15531
|
* limitations under the License.
|
|
15514
15532
|
*/
|
|
15515
15533
|
/**
|
|
15516
|
-
*
|
|
15517
|
-
*
|
|
15518
|
-
*
|
|
15519
|
-
*
|
|
15534
|
+
* The Firestore query engine.
|
|
15535
|
+
*
|
|
15536
|
+
* Firestore queries can be executed in three modes. The Query Engine determines
|
|
15537
|
+
* what mode to use based on what data is persisted. The mode only determines
|
|
15538
|
+
* the runtime complexity of the query - the result set is equivalent across all
|
|
15539
|
+
* implementations.
|
|
15540
|
+
*
|
|
15541
|
+
* The Query engine will use indexed-based execution if a user has configured
|
|
15542
|
+
* any index that can be used to execute query (via `setIndexConfiguration()`).
|
|
15543
|
+
* Otherwise, the engine will try to optimize the query by re-using a previously
|
|
15544
|
+
* persisted query result. If that is not possible, the query will be executed
|
|
15545
|
+
* via a full collection scan.
|
|
15546
|
+
*
|
|
15547
|
+
* Index-based execution is the default when available. The query engine
|
|
15548
|
+
* supports partial indexed execution and merges the result from the index
|
|
15549
|
+
* lookup with documents that have not yet been indexed. The index evaluation
|
|
15550
|
+
* matches the backend's format and as such, the SDK can use indexing for all
|
|
15551
|
+
* queries that the backend supports.
|
|
15552
|
+
*
|
|
15553
|
+
* If no index exists, the query engine tries to take advantage of the target
|
|
15554
|
+
* document mapping in the TargetCache. These mappings exists for all queries
|
|
15555
|
+
* that have been synced with the backend at least once and allow the query
|
|
15556
|
+
* engine to only read documents that previously matched a query plus any
|
|
15557
|
+
* documents that were edited after the query was last listened to.
|
|
15520
15558
|
*
|
|
15521
15559
|
* There are some cases when this optimization is not guaranteed to produce
|
|
15522
15560
|
* the same results as full collection scans. In these cases, query
|
|
@@ -15531,16 +15569,41 @@ class MemoryEagerDelegate {
|
|
|
15531
15569
|
* - Queries that have never been CURRENT or free of limbo documents.
|
|
15532
15570
|
*/
|
|
15533
15571
|
class QueryEngine {
|
|
15572
|
+
constructor() {
|
|
15573
|
+
this.initialized = false;
|
|
15574
|
+
}
|
|
15534
15575
|
/** Sets the document view to query against. */
|
|
15535
|
-
|
|
15576
|
+
initialize(localDocuments, indexManager) {
|
|
15536
15577
|
this.localDocumentsView = localDocuments;
|
|
15578
|
+
this.indexManager = indexManager;
|
|
15579
|
+
this.initialized = true;
|
|
15537
15580
|
}
|
|
15538
15581
|
/** Returns all local documents matching the specified query. */
|
|
15539
15582
|
getDocumentsMatchingQuery(transaction, query, lastLimboFreeSnapshotVersion, remoteKeys) {
|
|
15540
|
-
|
|
15541
|
-
|
|
15542
|
-
|
|
15543
|
-
|
|
15583
|
+
return this.performQueryUsingIndex(transaction, query)
|
|
15584
|
+
.next(result => result
|
|
15585
|
+
? result
|
|
15586
|
+
: this.performQueryUsingRemoteKeys(transaction, query, remoteKeys, lastLimboFreeSnapshotVersion))
|
|
15587
|
+
.next(result => result ? result : this.executeFullCollectionScan(transaction, query));
|
|
15588
|
+
}
|
|
15589
|
+
/**
|
|
15590
|
+
* Performs an indexed query that evaluates the query based on a collection's
|
|
15591
|
+
* persisted index values. Returns `null` if an index is not available.
|
|
15592
|
+
*/
|
|
15593
|
+
performQueryUsingIndex(transaction, query) {
|
|
15594
|
+
{
|
|
15595
|
+
return PersistencePromise.resolve(null);
|
|
15596
|
+
}
|
|
15597
|
+
}
|
|
15598
|
+
/**
|
|
15599
|
+
* Performs a query based on the target's persisted query mapping. Returns
|
|
15600
|
+
* `null` if the mapping is not available or cannot be used.
|
|
15601
|
+
*/
|
|
15602
|
+
performQueryUsingRemoteKeys(transaction, query, remoteKeys, lastLimboFreeSnapshotVersion) {
|
|
15603
|
+
if (queryMatchesAllDocuments(query)) {
|
|
15604
|
+
// Queries that match all documents don't benefit from using
|
|
15605
|
+
// key-based lookups. It is more efficient to scan all documents in a
|
|
15606
|
+
// collection, rather than to perform individual lookups.
|
|
15544
15607
|
return this.executeFullCollectionScan(transaction, query);
|
|
15545
15608
|
}
|
|
15546
15609
|
// Queries that have never seen a snapshot without limbo free documents
|
|
@@ -15550,8 +15613,7 @@ class QueryEngine {
|
|
|
15550
15613
|
}
|
|
15551
15614
|
return this.localDocumentsView.getDocuments(transaction, remoteKeys).next(documents => {
|
|
15552
15615
|
const previousResults = this.applyQuery(query, documents);
|
|
15553
|
-
if ((
|
|
15554
|
-
this.needsRefill(query.limitType, previousResults, remoteKeys, lastLimboFreeSnapshotVersion)) {
|
|
15616
|
+
if (this.needsRefill(query, previousResults, remoteKeys, lastLimboFreeSnapshotVersion)) {
|
|
15555
15617
|
return this.executeFullCollectionScan(transaction, query);
|
|
15556
15618
|
}
|
|
15557
15619
|
if (getLogLevel() <= LogLevel.DEBUG) {
|
|
@@ -15559,15 +15621,7 @@ class QueryEngine {
|
|
|
15559
15621
|
}
|
|
15560
15622
|
// Retrieve all results for documents that were updated since the last
|
|
15561
15623
|
// limbo-document free remote snapshot.
|
|
15562
|
-
return this.
|
|
15563
|
-
// We merge `previousResults` into `updateResults`, since
|
|
15564
|
-
// `updateResults` is already a DocumentMap. If a document is
|
|
15565
|
-
// contained in both lists, then its contents are the same.
|
|
15566
|
-
previousResults.forEach(doc => {
|
|
15567
|
-
updatedResults = updatedResults.insert(doc.key, doc);
|
|
15568
|
-
});
|
|
15569
|
-
return updatedResults;
|
|
15570
|
-
});
|
|
15624
|
+
return this.appendRemainingResults(transaction, previousResults, query, newIndexOffsetSuccessorFromReadTime(lastLimboFreeSnapshotVersion, INITIAL_LARGEST_BATCH_ID));
|
|
15571
15625
|
});
|
|
15572
15626
|
}
|
|
15573
15627
|
/** Applies the query filter and sorting to the provided documents. */
|
|
@@ -15586,6 +15640,7 @@ class QueryEngine {
|
|
|
15586
15640
|
* Determines if a limit query needs to be refilled from cache, making it
|
|
15587
15641
|
* ineligible for index-free execution.
|
|
15588
15642
|
*
|
|
15643
|
+
* @param query The query.
|
|
15589
15644
|
* @param sortedPreviousResults - The documents that matched the query when it
|
|
15590
15645
|
* was last synchronized, sorted by the query's comparator.
|
|
15591
15646
|
* @param remoteKeys - The document keys that matched the query at the last
|
|
@@ -15593,10 +15648,14 @@ class QueryEngine {
|
|
|
15593
15648
|
* @param limboFreeSnapshotVersion - The version of the snapshot when the
|
|
15594
15649
|
* query was last synchronized.
|
|
15595
15650
|
*/
|
|
15596
|
-
needsRefill(
|
|
15597
|
-
|
|
15598
|
-
|
|
15651
|
+
needsRefill(query, sortedPreviousResults, remoteKeys, limboFreeSnapshotVersion) {
|
|
15652
|
+
if (query.limit === null) {
|
|
15653
|
+
// Queries without limits do not need to be refilled.
|
|
15654
|
+
return false;
|
|
15655
|
+
}
|
|
15599
15656
|
if (remoteKeys.size !== sortedPreviousResults.size) {
|
|
15657
|
+
// The query needs to be refilled if a previously matching document no
|
|
15658
|
+
// longer matches.
|
|
15600
15659
|
return true;
|
|
15601
15660
|
}
|
|
15602
15661
|
// Limit queries are not eligible for index-free query execution if there is
|
|
@@ -15607,7 +15666,7 @@ class QueryEngine {
|
|
|
15607
15666
|
// the boundary of the limit itself did not change and documents from cache
|
|
15608
15667
|
// will continue to be "rejected" by this boundary. Therefore, we can ignore
|
|
15609
15668
|
// any modifications that don't affect the last document.
|
|
15610
|
-
const docAtLimitEdge = limitType === "F" /* First */
|
|
15669
|
+
const docAtLimitEdge = query.limitType === "F" /* First */
|
|
15611
15670
|
? sortedPreviousResults.last()
|
|
15612
15671
|
: sortedPreviousResults.first();
|
|
15613
15672
|
if (!docAtLimitEdge) {
|
|
@@ -15623,6 +15682,22 @@ class QueryEngine {
|
|
|
15623
15682
|
}
|
|
15624
15683
|
return this.localDocumentsView.getDocumentsMatchingQuery(transaction, query, IndexOffset.min());
|
|
15625
15684
|
}
|
|
15685
|
+
/**
|
|
15686
|
+
* Combines the results from an indexed execution with the remaining documents
|
|
15687
|
+
* that have not yet been indexed.
|
|
15688
|
+
*/
|
|
15689
|
+
appendRemainingResults(transaction, indexedResults, query, offset) {
|
|
15690
|
+
// Retrieve all results for documents that were updated since the offset.
|
|
15691
|
+
return this.localDocumentsView
|
|
15692
|
+
.getDocumentsMatchingQuery(transaction, query, offset)
|
|
15693
|
+
.next(remainingResults => {
|
|
15694
|
+
// Merge with existing results
|
|
15695
|
+
indexedResults.forEach(d => {
|
|
15696
|
+
remainingResults = remainingResults.insert(d.key, d);
|
|
15697
|
+
});
|
|
15698
|
+
return remainingResults;
|
|
15699
|
+
});
|
|
15700
|
+
}
|
|
15626
15701
|
}
|
|
15627
15702
|
|
|
15628
15703
|
/**
|
|
@@ -21882,10 +21957,12 @@ class View {
|
|
|
21882
21957
|
//
|
|
21883
21958
|
// Note that this should never get used in a refill (when previousChanges is
|
|
21884
21959
|
// set), because there will only be adds -- no deletes or updates.
|
|
21885
|
-
const lastDocInLimit =
|
|
21960
|
+
const lastDocInLimit = this.query.limitType === "F" /* First */ &&
|
|
21961
|
+
oldDocumentSet.size === this.query.limit
|
|
21886
21962
|
? oldDocumentSet.last()
|
|
21887
21963
|
: null;
|
|
21888
|
-
const firstDocInLimit =
|
|
21964
|
+
const firstDocInLimit = this.query.limitType === "L" /* Last */ &&
|
|
21965
|
+
oldDocumentSet.size === this.query.limit
|
|
21889
21966
|
? oldDocumentSet.first()
|
|
21890
21967
|
: null;
|
|
21891
21968
|
docChanges.inorderTraversal((key, entry) => {
|
|
@@ -21958,9 +22035,9 @@ class View {
|
|
|
21958
22035
|
}
|
|
21959
22036
|
});
|
|
21960
22037
|
// Drop documents out to meet limit/limitToLast requirement.
|
|
21961
|
-
if (
|
|
22038
|
+
if (this.query.limit !== null) {
|
|
21962
22039
|
while (newDocumentSet.size > this.query.limit) {
|
|
21963
|
-
const oldDoc =
|
|
22040
|
+
const oldDoc = this.query.limitType === "F" /* First */
|
|
21964
22041
|
? newDocumentSet.last()
|
|
21965
22042
|
: newDocumentSet.first();
|
|
21966
22043
|
newDocumentSet = newDocumentSet.delete(oldDoc.key);
|
|
@@ -27091,7 +27168,8 @@ function snapshotEqual(left, right) {
|
|
|
27091
27168
|
* limitations under the License.
|
|
27092
27169
|
*/
|
|
27093
27170
|
function validateHasExplicitOrderByForLimitToLast(query) {
|
|
27094
|
-
if (
|
|
27171
|
+
if (query.limitType === "L" /* Last */ &&
|
|
27172
|
+
query.explicitOrderBy.length === 0) {
|
|
27095
27173
|
throw new FirestoreError(Code.UNIMPLEMENTED, 'limitToLast() queries require specifying at least one orderBy() clause');
|
|
27096
27174
|
}
|
|
27097
27175
|
}
|