@firebase/firestore 3.4.4-canary.2dd99ae2d → 3.4.4-canary.7f959622d
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/target.d.ts +8 -4
- package/dist/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/firestore/test/util/helpers.d.ts +1 -1
- package/dist/index.esm2017.js +2233 -2144
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2964 -2912
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +199 -90
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +199 -90
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +2183 -2090
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/lite/firestore/src/core/target.d.ts +8 -4
- package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/lite/firestore/test/util/helpers.d.ts +1 -1
- package/dist/lite/index.browser.esm2017.js +301 -298
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +327 -326
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +36 -29
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +36 -29
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +301 -298
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +2 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +90 -90
- package/dist/lite/packages/firestore/src/core/target.d.ts +8 -4
- package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +1 -1
- package/dist/lite/private.d.ts +2 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +61 -61
- package/dist/packages/firestore/src/core/target.d.ts +8 -4
- package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/packages/firestore/test/util/helpers.d.ts +1 -1
- package/dist/private.d.ts +2 -2
- package/package.json +9 -9
package/dist/index.node.cjs.js
CHANGED
|
@@ -12,7 +12,7 @@ var grpcJs = require('@grpc/grpc-js');
|
|
|
12
12
|
var protoLoader = require('@grpc/proto-loader');
|
|
13
13
|
|
|
14
14
|
const name = "@firebase/firestore";
|
|
15
|
-
const version$1 = "3.4.4-canary.
|
|
15
|
+
const version$1 = "3.4.4-canary.7f959622d";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @license
|
|
@@ -65,7 +65,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
65
65
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
66
66
|
User.MOCK_USER = new User('mock-user');
|
|
67
67
|
|
|
68
|
-
const version = "9.6.5-canary.
|
|
68
|
+
const version = "9.6.5-canary.7f959622d";
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* @license
|
|
@@ -1196,23 +1196,6 @@ function decodeResourcePath(path) {
|
|
|
1196
1196
|
}
|
|
1197
1197
|
return new ResourcePath(segments);
|
|
1198
1198
|
}
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* @license
|
|
1202
|
-
* Copyright 2017 Google LLC
|
|
1203
|
-
*
|
|
1204
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1205
|
-
* you may not use this file except in compliance with the License.
|
|
1206
|
-
* You may obtain a copy of the License at
|
|
1207
|
-
*
|
|
1208
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1209
|
-
*
|
|
1210
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1211
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1212
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1213
|
-
* See the License for the specific language governing permissions and
|
|
1214
|
-
* limitations under the License.
|
|
1215
|
-
*/
|
|
1216
1199
|
/**
|
|
1217
1200
|
* Schema Version for the Web client:
|
|
1218
1201
|
* 1. Initial version including Mutation Queue, Query Cache, and Remote
|
|
@@ -1231,6 +1214,7 @@ function decodeResourcePath(path) {
|
|
|
1231
1214
|
* an auto-incrementing ID. This is required for Index-Free queries.
|
|
1232
1215
|
* 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
|
|
1233
1216
|
* 11. Add bundles and named_queries for bundle support.
|
|
1217
|
+
* 12. Add indexing support.
|
|
1234
1218
|
*/
|
|
1235
1219
|
const SCHEMA_VERSION = 11;
|
|
1236
1220
|
/**
|
|
@@ -1757,9 +1741,7 @@ class DbClientMetadata {
|
|
|
1757
1741
|
DbClientMetadata.store = 'clientMetadata';
|
|
1758
1742
|
/** Keys are automatically assigned via the clientId properties. */
|
|
1759
1743
|
DbClientMetadata.keyPath = 'clientId';
|
|
1760
|
-
/**
|
|
1761
|
-
* A object representing a bundle loaded by the SDK.
|
|
1762
|
-
*/
|
|
1744
|
+
/** An object representing a bundle loaded by the SDK. */
|
|
1763
1745
|
class DbBundle {
|
|
1764
1746
|
constructor(
|
|
1765
1747
|
/** The ID of the loaded bundle. */
|
|
@@ -1776,9 +1758,7 @@ class DbBundle {
|
|
|
1776
1758
|
/** Name of the IndexedDb object store. */
|
|
1777
1759
|
DbBundle.store = 'bundles';
|
|
1778
1760
|
DbBundle.keyPath = 'bundleId';
|
|
1779
|
-
/**
|
|
1780
|
-
* A object representing a named query loaded by the SDK via a bundle.
|
|
1781
|
-
*/
|
|
1761
|
+
/** An object representing a named query loaded by the SDK via a bundle. */
|
|
1782
1762
|
class DbNamedQuery {
|
|
1783
1763
|
constructor(
|
|
1784
1764
|
/** The name of the query. */
|
|
@@ -1795,6 +1775,93 @@ class DbNamedQuery {
|
|
|
1795
1775
|
/** Name of the IndexedDb object store. */
|
|
1796
1776
|
DbNamedQuery.store = 'namedQueries';
|
|
1797
1777
|
DbNamedQuery.keyPath = 'name';
|
|
1778
|
+
/** An object representing the global configuration for a field index. */
|
|
1779
|
+
class DbIndexConfiguration {
|
|
1780
|
+
constructor(
|
|
1781
|
+
/** The index id for this entry. */
|
|
1782
|
+
indexId,
|
|
1783
|
+
/** The collection group this index belongs to. */
|
|
1784
|
+
collectionGroup,
|
|
1785
|
+
/** The fields to index for this index. */
|
|
1786
|
+
fields) {
|
|
1787
|
+
this.indexId = indexId;
|
|
1788
|
+
this.collectionGroup = collectionGroup;
|
|
1789
|
+
this.fields = fields;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
/** Name of the IndexedDb object store. */
|
|
1793
|
+
DbIndexConfiguration.store = 'indexConfiguration';
|
|
1794
|
+
DbIndexConfiguration.keyPath = 'indexId';
|
|
1795
|
+
/**
|
|
1796
|
+
* An object describing how up-to-date the index backfill is for each user and
|
|
1797
|
+
* index.
|
|
1798
|
+
*/
|
|
1799
|
+
class DbIndexState {
|
|
1800
|
+
constructor(
|
|
1801
|
+
/** The index id for this entry. */
|
|
1802
|
+
indexId,
|
|
1803
|
+
/** The user id for this entry. */
|
|
1804
|
+
uid,
|
|
1805
|
+
/**
|
|
1806
|
+
* A number that indicates when the index was last updated (relative to
|
|
1807
|
+
* other indexes).
|
|
1808
|
+
*/
|
|
1809
|
+
sequenceNumber,
|
|
1810
|
+
/**
|
|
1811
|
+
* The latest read time that has been indexed by Firestore for this field
|
|
1812
|
+
* index. Set to `{seconds: 0, nanos: 0}` if no documents have been indexed.
|
|
1813
|
+
*/
|
|
1814
|
+
readTime,
|
|
1815
|
+
/**
|
|
1816
|
+
* The last document that has been indexed for this field index. Empty if
|
|
1817
|
+
* no documents have been indexed.
|
|
1818
|
+
*/
|
|
1819
|
+
documentKey,
|
|
1820
|
+
/**
|
|
1821
|
+
* The largest mutation batch id that has been processed for this index. -1
|
|
1822
|
+
* if no mutations have been indexed.
|
|
1823
|
+
*/
|
|
1824
|
+
largestBatchId) {
|
|
1825
|
+
this.indexId = indexId;
|
|
1826
|
+
this.uid = uid;
|
|
1827
|
+
this.sequenceNumber = sequenceNumber;
|
|
1828
|
+
this.readTime = readTime;
|
|
1829
|
+
this.documentKey = documentKey;
|
|
1830
|
+
this.largestBatchId = largestBatchId;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
/** Name of the IndexedDb object store. */
|
|
1834
|
+
DbIndexState.store = 'indexState';
|
|
1835
|
+
DbIndexState.keyPath = ['indexId', 'uid'];
|
|
1836
|
+
/** An object that stores the encoded entries for all documents and fields. */
|
|
1837
|
+
class DbIndexEntries {
|
|
1838
|
+
constructor(
|
|
1839
|
+
/** The index id for this entry. */
|
|
1840
|
+
indexId,
|
|
1841
|
+
/** The user id for this entry. */
|
|
1842
|
+
uid,
|
|
1843
|
+
/** The encoded array index value for this entry. */
|
|
1844
|
+
arrayValue,
|
|
1845
|
+
/** The encoded directional value for equality and inequality filters. */
|
|
1846
|
+
directionalValue,
|
|
1847
|
+
/** The document key this entry points to. */
|
|
1848
|
+
documentKey) {
|
|
1849
|
+
this.indexId = indexId;
|
|
1850
|
+
this.uid = uid;
|
|
1851
|
+
this.arrayValue = arrayValue;
|
|
1852
|
+
this.directionalValue = directionalValue;
|
|
1853
|
+
this.documentKey = documentKey;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
/** Name of the IndexedDb object store. */
|
|
1857
|
+
DbIndexEntries.store = 'indexEntries';
|
|
1858
|
+
DbIndexEntries.keyPath = [
|
|
1859
|
+
'indexId',
|
|
1860
|
+
'uid',
|
|
1861
|
+
'arrayValue',
|
|
1862
|
+
'directionalValue',
|
|
1863
|
+
'documentKey'
|
|
1864
|
+
];
|
|
1798
1865
|
// Visible for testing
|
|
1799
1866
|
const V1_STORES = [
|
|
1800
1867
|
DbMutationQueue.store,
|
|
@@ -1809,7 +1876,6 @@ const V1_STORES = [
|
|
|
1809
1876
|
// V2 is no longer usable (see comment at top of file)
|
|
1810
1877
|
// Visible for testing
|
|
1811
1878
|
const V3_STORES = V1_STORES;
|
|
1812
|
-
// Visible for testing
|
|
1813
1879
|
// Note: DbRemoteDocumentChanges is no longer used and dropped with v9.
|
|
1814
1880
|
const V4_STORES = [...V3_STORES, DbClientMetadata.store];
|
|
1815
1881
|
// V5 does not change the set of stores.
|
|
@@ -1819,6 +1885,12 @@ const V8_STORES = [...V6_STORES, DbCollectionParent.store];
|
|
|
1819
1885
|
// V9 does not change the set of stores.
|
|
1820
1886
|
// V10 does not change the set of stores.
|
|
1821
1887
|
const V11_STORES = [...V8_STORES, DbBundle.store, DbNamedQuery.store];
|
|
1888
|
+
[
|
|
1889
|
+
...V11_STORES,
|
|
1890
|
+
DbIndexConfiguration.store,
|
|
1891
|
+
DbIndexState.store,
|
|
1892
|
+
DbIndexEntries.store
|
|
1893
|
+
];
|
|
1822
1894
|
/**
|
|
1823
1895
|
* The list of all default IndexedDB stores used throughout the SDK. This is
|
|
1824
1896
|
* used when creating transactions so that access across all stores is done
|
|
@@ -4464,27 +4536,29 @@ function newTarget(path, collectionGroup = null, orderBy = [], filters = [], lim
|
|
|
4464
4536
|
function canonifyTarget(target) {
|
|
4465
4537
|
const targetImpl = debugCast(target);
|
|
4466
4538
|
if (targetImpl.memoizedCanonicalId === null) {
|
|
4467
|
-
let
|
|
4539
|
+
let str = targetImpl.path.canonicalString();
|
|
4468
4540
|
if (targetImpl.collectionGroup !== null) {
|
|
4469
|
-
|
|
4541
|
+
str += '|cg:' + targetImpl.collectionGroup;
|
|
4470
4542
|
}
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4543
|
+
str += '|f:';
|
|
4544
|
+
str += targetImpl.filters.map(f => canonifyFilter(f)).join(',');
|
|
4545
|
+
str += '|ob:';
|
|
4546
|
+
str += targetImpl.orderBy.map(o => canonifyOrderBy(o)).join(',');
|
|
4475
4547
|
if (!isNullOrUndefined(targetImpl.limit)) {
|
|
4476
|
-
|
|
4477
|
-
|
|
4548
|
+
str += '|l:';
|
|
4549
|
+
str += targetImpl.limit;
|
|
4478
4550
|
}
|
|
4479
4551
|
if (targetImpl.startAt) {
|
|
4480
|
-
|
|
4481
|
-
|
|
4552
|
+
str += '|lb:';
|
|
4553
|
+
str += targetImpl.startAt.inclusive ? 'b:' : 'a:';
|
|
4554
|
+
str += targetImpl.startAt.position.map(p => canonicalId(p)).join(',');
|
|
4482
4555
|
}
|
|
4483
4556
|
if (targetImpl.endAt) {
|
|
4484
|
-
|
|
4485
|
-
|
|
4557
|
+
str += '|ub:';
|
|
4558
|
+
str += targetImpl.endAt.inclusive ? 'a:' : 'b:';
|
|
4559
|
+
str += targetImpl.endAt.position.map(p => canonicalId(p)).join(',');
|
|
4486
4560
|
}
|
|
4487
|
-
targetImpl.memoizedCanonicalId =
|
|
4561
|
+
targetImpl.memoizedCanonicalId = str;
|
|
4488
4562
|
}
|
|
4489
4563
|
return targetImpl.memoizedCanonicalId;
|
|
4490
4564
|
}
|
|
@@ -4507,10 +4581,14 @@ function stringifyTarget(target) {
|
|
|
4507
4581
|
.join(', ')}]`;
|
|
4508
4582
|
}
|
|
4509
4583
|
if (target.startAt) {
|
|
4510
|
-
str += ', startAt: '
|
|
4584
|
+
str += ', startAt: ';
|
|
4585
|
+
str += target.startAt.inclusive ? 'b:' : 'a:';
|
|
4586
|
+
str += target.startAt.position.map(p => canonicalId(p)).join(',');
|
|
4511
4587
|
}
|
|
4512
4588
|
if (target.endAt) {
|
|
4513
|
-
str += ', endAt: '
|
|
4589
|
+
str += ', endAt: ';
|
|
4590
|
+
str += target.endAt.inclusive ? 'a:' : 'b:';
|
|
4591
|
+
str += target.endAt.position.map(p => canonicalId(p)).join(',');
|
|
4514
4592
|
}
|
|
4515
4593
|
return `Target(${str})`;
|
|
4516
4594
|
}
|
|
@@ -4733,7 +4811,6 @@ class ArrayContainsAnyFilter extends FieldFilter {
|
|
|
4733
4811
|
return other.arrayValue.values.some(val => arrayValueContains(this.value.arrayValue, val));
|
|
4734
4812
|
}
|
|
4735
4813
|
}
|
|
4736
|
-
// TODO(indexing): Change Bound.before to "inclusive"
|
|
4737
4814
|
/**
|
|
4738
4815
|
* Represents a bound of a query.
|
|
4739
4816
|
*
|
|
@@ -4749,17 +4826,11 @@ class ArrayContainsAnyFilter extends FieldFilter {
|
|
|
4749
4826
|
* just after the provided values.
|
|
4750
4827
|
*/
|
|
4751
4828
|
class Bound {
|
|
4752
|
-
constructor(position,
|
|
4829
|
+
constructor(position, inclusive) {
|
|
4753
4830
|
this.position = position;
|
|
4754
|
-
this.
|
|
4831
|
+
this.inclusive = inclusive;
|
|
4755
4832
|
}
|
|
4756
4833
|
}
|
|
4757
|
-
function canonifyBound(bound) {
|
|
4758
|
-
// TODO(b/29183165): Make this collision robust.
|
|
4759
|
-
return `${bound.before ? 'b' : 'a'}:${bound.position
|
|
4760
|
-
.map(p => canonicalId(p))
|
|
4761
|
-
.join(',')}`;
|
|
4762
|
-
}
|
|
4763
4834
|
/**
|
|
4764
4835
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
4765
4836
|
*/
|
|
@@ -4779,11 +4850,7 @@ function stringifyOrderBy(orderBy) {
|
|
|
4779
4850
|
function orderByEquals(left, right) {
|
|
4780
4851
|
return left.dir === right.dir && left.field.isEqual(right.field);
|
|
4781
4852
|
}
|
|
4782
|
-
|
|
4783
|
-
* Returns true if a document sorts before a bound using the provided sort
|
|
4784
|
-
* order.
|
|
4785
|
-
*/
|
|
4786
|
-
function sortsBeforeDocument(bound, orderBy, doc) {
|
|
4853
|
+
function boundCompareToDocument(bound, orderBy, doc) {
|
|
4787
4854
|
let comparison = 0;
|
|
4788
4855
|
for (let i = 0; i < bound.position.length; i++) {
|
|
4789
4856
|
const orderByComponent = orderBy[i];
|
|
@@ -4802,7 +4869,23 @@ function sortsBeforeDocument(bound, orderBy, doc) {
|
|
|
4802
4869
|
break;
|
|
4803
4870
|
}
|
|
4804
4871
|
}
|
|
4805
|
-
return
|
|
4872
|
+
return comparison;
|
|
4873
|
+
}
|
|
4874
|
+
/**
|
|
4875
|
+
* Returns true if a document sorts after a bound using the provided sort
|
|
4876
|
+
* order.
|
|
4877
|
+
*/
|
|
4878
|
+
function boundSortsAfterDocument(bound, orderBy, doc) {
|
|
4879
|
+
const comparison = boundCompareToDocument(bound, orderBy, doc);
|
|
4880
|
+
return bound.inclusive ? comparison >= 0 : comparison > 0;
|
|
4881
|
+
}
|
|
4882
|
+
/**
|
|
4883
|
+
* Returns true if a document sorts before a bound using the provided sort
|
|
4884
|
+
* order.
|
|
4885
|
+
*/
|
|
4886
|
+
function boundSortsBeforeDocument(bound, orderBy, doc) {
|
|
4887
|
+
const comparison = boundCompareToDocument(bound, orderBy, doc);
|
|
4888
|
+
return bound.inclusive ? comparison <= 0 : comparison < 0;
|
|
4806
4889
|
}
|
|
4807
4890
|
function boundEquals(left, right) {
|
|
4808
4891
|
if (left === null) {
|
|
@@ -4811,7 +4894,7 @@ function boundEquals(left, right) {
|
|
|
4811
4894
|
else if (right === null) {
|
|
4812
4895
|
return false;
|
|
4813
4896
|
}
|
|
4814
|
-
if (left.
|
|
4897
|
+
if (left.inclusive !== right.inclusive ||
|
|
4815
4898
|
left.position.length !== right.position.length) {
|
|
4816
4899
|
return false;
|
|
4817
4900
|
}
|
|
@@ -5015,10 +5098,10 @@ function queryToTarget(query) {
|
|
|
5015
5098
|
}
|
|
5016
5099
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
5017
5100
|
const startAt = queryImpl.endAt
|
|
5018
|
-
? new Bound(queryImpl.endAt.position, !queryImpl.endAt.
|
|
5101
|
+
? new Bound(queryImpl.endAt.position, !queryImpl.endAt.inclusive)
|
|
5019
5102
|
: null;
|
|
5020
5103
|
const endAt = queryImpl.startAt
|
|
5021
|
-
? new Bound(queryImpl.startAt.position, !queryImpl.startAt.
|
|
5104
|
+
? new Bound(queryImpl.startAt.position, !queryImpl.startAt.inclusive)
|
|
5022
5105
|
: null;
|
|
5023
5106
|
// Now return as a LimitType.First query.
|
|
5024
5107
|
queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
|
|
@@ -5106,11 +5189,11 @@ function queryMatchesFilters(query, doc) {
|
|
|
5106
5189
|
/** Makes sure a document is within the bounds, if provided. */
|
|
5107
5190
|
function queryMatchesBounds(query, doc) {
|
|
5108
5191
|
if (query.startAt &&
|
|
5109
|
-
!
|
|
5192
|
+
!boundSortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
|
|
5110
5193
|
return false;
|
|
5111
5194
|
}
|
|
5112
5195
|
if (query.endAt &&
|
|
5113
|
-
|
|
5196
|
+
!boundSortsAfterDocument(query.endAt, queryOrderBy(query), doc)) {
|
|
5114
5197
|
return false;
|
|
5115
5198
|
}
|
|
5116
5199
|
return true;
|
|
@@ -7989,10 +8072,10 @@ function toQueryTarget(serializer, target) {
|
|
|
7989
8072
|
result.structuredQuery.limit = limit;
|
|
7990
8073
|
}
|
|
7991
8074
|
if (target.startAt) {
|
|
7992
|
-
result.structuredQuery.startAt =
|
|
8075
|
+
result.structuredQuery.startAt = toStartAtCursor(target.startAt);
|
|
7993
8076
|
}
|
|
7994
8077
|
if (target.endAt) {
|
|
7995
|
-
result.structuredQuery.endAt =
|
|
8078
|
+
result.structuredQuery.endAt = toEndAtCursor(target.endAt);
|
|
7996
8079
|
}
|
|
7997
8080
|
return result;
|
|
7998
8081
|
}
|
|
@@ -8025,11 +8108,11 @@ function convertQueryTargetToQuery(target) {
|
|
|
8025
8108
|
}
|
|
8026
8109
|
let startAt = null;
|
|
8027
8110
|
if (query.startAt) {
|
|
8028
|
-
startAt =
|
|
8111
|
+
startAt = fromStartAtCursor(query.startAt);
|
|
8029
8112
|
}
|
|
8030
8113
|
let endAt = null;
|
|
8031
8114
|
if (query.endAt) {
|
|
8032
|
-
endAt =
|
|
8115
|
+
endAt = fromEndAtCursor(query.endAt);
|
|
8033
8116
|
}
|
|
8034
8117
|
return newQuery(path, collectionGroup, orderBy, filterBy, limit, "F" /* First */, startAt, endAt);
|
|
8035
8118
|
}
|
|
@@ -8120,16 +8203,27 @@ function toOrder(orderBys) {
|
|
|
8120
8203
|
function fromOrder(orderBys) {
|
|
8121
8204
|
return orderBys.map(order => fromPropertyOrder(order));
|
|
8122
8205
|
}
|
|
8123
|
-
function
|
|
8206
|
+
function toStartAtCursor(cursor) {
|
|
8124
8207
|
return {
|
|
8125
|
-
before: cursor.
|
|
8208
|
+
before: cursor.inclusive,
|
|
8126
8209
|
values: cursor.position
|
|
8127
8210
|
};
|
|
8128
8211
|
}
|
|
8129
|
-
function
|
|
8130
|
-
|
|
8212
|
+
function toEndAtCursor(cursor) {
|
|
8213
|
+
return {
|
|
8214
|
+
before: !cursor.inclusive,
|
|
8215
|
+
values: cursor.position
|
|
8216
|
+
};
|
|
8217
|
+
}
|
|
8218
|
+
function fromStartAtCursor(cursor) {
|
|
8219
|
+
const inclusive = !!cursor.before;
|
|
8220
|
+
const position = cursor.values || [];
|
|
8221
|
+
return new Bound(position, inclusive);
|
|
8222
|
+
}
|
|
8223
|
+
function fromEndAtCursor(cursor) {
|
|
8224
|
+
const inclusive = !cursor.before;
|
|
8131
8225
|
const position = cursor.values || [];
|
|
8132
|
-
return new Bound(position,
|
|
8226
|
+
return new Bound(position, inclusive);
|
|
8133
8227
|
}
|
|
8134
8228
|
// visible for testing
|
|
8135
8229
|
function toDirection(dir) {
|
|
@@ -10641,9 +10735,6 @@ class SchemaConverter {
|
|
|
10641
10735
|
* and local feature development.
|
|
10642
10736
|
*/
|
|
10643
10737
|
createOrUpgrade(db, txn, fromVersion, toVersion) {
|
|
10644
|
-
hardAssert(fromVersion < toVersion &&
|
|
10645
|
-
fromVersion >= 0 &&
|
|
10646
|
-
toVersion <= SCHEMA_VERSION);
|
|
10647
10738
|
const simpleDbTransaction = new SimpleDbTransaction('createOrUpgrade', txn);
|
|
10648
10739
|
if (fromVersion < 1 && toVersion >= 1) {
|
|
10649
10740
|
createPrimaryClientStore(db);
|
|
@@ -10710,6 +10801,11 @@ class SchemaConverter {
|
|
|
10710
10801
|
createNamedQueriesStore(db);
|
|
10711
10802
|
});
|
|
10712
10803
|
}
|
|
10804
|
+
if (fromVersion < 12 && toVersion >= 12) {
|
|
10805
|
+
p = p.next(() => {
|
|
10806
|
+
createFieldIndex(db);
|
|
10807
|
+
});
|
|
10808
|
+
}
|
|
10713
10809
|
return p;
|
|
10714
10810
|
}
|
|
10715
10811
|
addDocumentGlobal(txn) {
|
|
@@ -10916,6 +11012,17 @@ function createNamedQueriesStore(db) {
|
|
|
10916
11012
|
db.createObjectStore(DbNamedQuery.store, {
|
|
10917
11013
|
keyPath: DbNamedQuery.keyPath
|
|
10918
11014
|
});
|
|
11015
|
+
}
|
|
11016
|
+
function createFieldIndex(db) {
|
|
11017
|
+
db.createObjectStore(DbIndexConfiguration.store, {
|
|
11018
|
+
keyPath: DbIndexConfiguration.keyPath
|
|
11019
|
+
});
|
|
11020
|
+
db.createObjectStore(DbIndexState.store, {
|
|
11021
|
+
keyPath: DbIndexState.keyPath
|
|
11022
|
+
});
|
|
11023
|
+
db.createObjectStore(DbIndexEntries.store, {
|
|
11024
|
+
keyPath: DbIndexEntries.keyPath
|
|
11025
|
+
});
|
|
10919
11026
|
}
|
|
10920
11027
|
|
|
10921
11028
|
/**
|
|
@@ -25232,51 +25339,53 @@ function limitToLast(limit) {
|
|
|
25232
25339
|
return new QueryLimitConstraint('limitToLast', limit, "L" /* Last */);
|
|
25233
25340
|
}
|
|
25234
25341
|
class QueryStartAtConstraint extends QueryConstraint {
|
|
25235
|
-
constructor(type, _docOrFields,
|
|
25342
|
+
constructor(type, _docOrFields, _inclusive) {
|
|
25236
25343
|
super();
|
|
25237
25344
|
this.type = type;
|
|
25238
25345
|
this._docOrFields = _docOrFields;
|
|
25239
|
-
this.
|
|
25346
|
+
this._inclusive = _inclusive;
|
|
25240
25347
|
}
|
|
25241
25348
|
_apply(query) {
|
|
25242
|
-
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this.
|
|
25349
|
+
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
|
|
25243
25350
|
return new Query(query.firestore, query.converter, queryWithStartAt(query._query, bound));
|
|
25244
25351
|
}
|
|
25245
25352
|
}
|
|
25246
25353
|
function startAt(...docOrFields) {
|
|
25247
|
-
return new QueryStartAtConstraint('startAt', docOrFields,
|
|
25354
|
+
return new QueryStartAtConstraint('startAt', docOrFields,
|
|
25355
|
+
/*inclusive=*/ true);
|
|
25248
25356
|
}
|
|
25249
25357
|
function startAfter(...docOrFields) {
|
|
25250
25358
|
return new QueryStartAtConstraint('startAfter', docOrFields,
|
|
25251
|
-
/*
|
|
25359
|
+
/*inclusive=*/ false);
|
|
25252
25360
|
}
|
|
25253
25361
|
class QueryEndAtConstraint extends QueryConstraint {
|
|
25254
|
-
constructor(type, _docOrFields,
|
|
25362
|
+
constructor(type, _docOrFields, _inclusive) {
|
|
25255
25363
|
super();
|
|
25256
25364
|
this.type = type;
|
|
25257
25365
|
this._docOrFields = _docOrFields;
|
|
25258
|
-
this.
|
|
25366
|
+
this._inclusive = _inclusive;
|
|
25259
25367
|
}
|
|
25260
25368
|
_apply(query) {
|
|
25261
|
-
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this.
|
|
25369
|
+
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
|
|
25262
25370
|
return new Query(query.firestore, query.converter, queryWithEndAt(query._query, bound));
|
|
25263
25371
|
}
|
|
25264
25372
|
}
|
|
25265
25373
|
function endBefore(...docOrFields) {
|
|
25266
|
-
return new QueryEndAtConstraint('endBefore', docOrFields,
|
|
25374
|
+
return new QueryEndAtConstraint('endBefore', docOrFields,
|
|
25375
|
+
/*inclusive=*/ false);
|
|
25267
25376
|
}
|
|
25268
25377
|
function endAt(...docOrFields) {
|
|
25269
|
-
return new QueryEndAtConstraint('endAt', docOrFields, /*
|
|
25378
|
+
return new QueryEndAtConstraint('endAt', docOrFields, /*inclusive=*/ true);
|
|
25270
25379
|
}
|
|
25271
25380
|
/** Helper function to create a bound from a document or fields */
|
|
25272
|
-
function newQueryBoundFromDocOrFields(query, methodName, docOrFields,
|
|
25381
|
+
function newQueryBoundFromDocOrFields(query, methodName, docOrFields, inclusive) {
|
|
25273
25382
|
docOrFields[0] = util$1.getModularInstance(docOrFields[0]);
|
|
25274
25383
|
if (docOrFields[0] instanceof DocumentSnapshot$1) {
|
|
25275
|
-
return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document,
|
|
25384
|
+
return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, inclusive);
|
|
25276
25385
|
}
|
|
25277
25386
|
else {
|
|
25278
25387
|
const reader = newUserDataReader(query.firestore);
|
|
25279
|
-
return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields,
|
|
25388
|
+
return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, inclusive);
|
|
25280
25389
|
}
|
|
25281
25390
|
}
|
|
25282
25391
|
function newQueryFilter(query, methodName, dataReader, databaseId, fieldPath, op, value) {
|
|
@@ -25334,7 +25443,7 @@ function newQueryOrderBy(query, fieldPath, direction) {
|
|
|
25334
25443
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
25335
25444
|
* server timestamp.
|
|
25336
25445
|
*/
|
|
25337
|
-
function newQueryBoundFromDocument(query, databaseId, methodName, doc,
|
|
25446
|
+
function newQueryBoundFromDocument(query, databaseId, methodName, doc, inclusive) {
|
|
25338
25447
|
if (!doc) {
|
|
25339
25448
|
throw new FirestoreError(Code.NOT_FOUND, `Can't use a DocumentSnapshot that doesn't exist for ` +
|
|
25340
25449
|
`${methodName}().`);
|
|
@@ -25371,12 +25480,12 @@ function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
|
|
|
25371
25480
|
}
|
|
25372
25481
|
}
|
|
25373
25482
|
}
|
|
25374
|
-
return new Bound(components,
|
|
25483
|
+
return new Bound(components, inclusive);
|
|
25375
25484
|
}
|
|
25376
25485
|
/**
|
|
25377
25486
|
* Converts a list of field values to a `Bound` for the given query.
|
|
25378
25487
|
*/
|
|
25379
|
-
function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values,
|
|
25488
|
+
function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, inclusive) {
|
|
25380
25489
|
// Use explicit order by's because it has to match the query the user made
|
|
25381
25490
|
const orderBy = query.explicitOrderBy;
|
|
25382
25491
|
if (values.length > orderBy.length) {
|
|
@@ -25413,7 +25522,7 @@ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, valu
|
|
|
25413
25522
|
components.push(wrapped);
|
|
25414
25523
|
}
|
|
25415
25524
|
}
|
|
25416
|
-
return new Bound(components,
|
|
25525
|
+
return new Bound(components, inclusive);
|
|
25417
25526
|
}
|
|
25418
25527
|
/**
|
|
25419
25528
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|