@firebase/firestore 3.4.7-canary.7343a55c4 → 3.4.7-canary.7a4e65cef
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/local/index_manager.d.ts +3 -2
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +11 -3
- package/dist/firestore/src/local/indexeddb_schema.d.ts +7 -2
- package/dist/firestore/src/local/indexeddb_sentinels.d.ts +9 -2
- package/dist/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/firestore/src/model/field_index.d.ts +6 -0
- package/dist/firestore/test/unit/local/test_index_manager.d.ts +3 -2
- package/dist/index.esm2017.js +3257 -3205
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3563 -3514
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +168 -117
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +168 -117
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3078 -3026
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/lite/firestore/src/local/index_manager.d.ts +3 -2
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +11 -3
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +7 -2
- package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +9 -2
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/lite/firestore/src/model/field_index.d.ts +6 -0
- package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +3 -2
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +2 -2
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1112 -1112
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +3 -2
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -3
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +7 -2
- package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +9 -2
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/lite/packages/firestore/src/model/field_index.d.ts +6 -0
- package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +3 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +163 -163
- package/dist/packages/firestore/src/local/index_manager.d.ts +3 -2
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -3
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +7 -2
- package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +9 -2
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/packages/firestore/src/model/field_index.d.ts +6 -0
- package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +3 -2
- package/dist/private.d.ts +1 -1
- package/package.json +9 -9
package/dist/index.node.cjs.js
CHANGED
|
@@ -33,7 +33,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
|
|
|
33
33
|
var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
|
|
34
34
|
|
|
35
35
|
const name = "@firebase/firestore";
|
|
36
|
-
const version$1 = "3.4.7-canary.
|
|
36
|
+
const version$1 = "3.4.7-canary.7a4e65cef";
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @license
|
|
@@ -86,7 +86,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
86
86
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
87
87
|
User.MOCK_USER = new User('mock-user');
|
|
88
88
|
|
|
89
|
-
const version = "9.6.10-canary.
|
|
89
|
+
const version = "9.6.10-canary.7a4e65cef";
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* @license
|
|
@@ -1418,13 +1418,14 @@ const DbIndexEntryKeyPath = [
|
|
|
1418
1418
|
'uid',
|
|
1419
1419
|
'arrayValue',
|
|
1420
1420
|
'directionalValue',
|
|
1421
|
+
'orderedDocumentKey',
|
|
1421
1422
|
'documentKey'
|
|
1422
1423
|
];
|
|
1423
1424
|
const DbIndexEntryDocumentKeyIndex = 'documentKeyIndex';
|
|
1424
1425
|
const DbIndexEntryDocumentKeyIndexPath = [
|
|
1425
1426
|
'indexId',
|
|
1426
1427
|
'uid',
|
|
1427
|
-
'
|
|
1428
|
+
'orderedDocumentKey'
|
|
1428
1429
|
];
|
|
1429
1430
|
/** Name of the IndexedDb object store. */
|
|
1430
1431
|
const DbDocumentOverlayStore = 'documentOverlays';
|
|
@@ -4221,6 +4222,17 @@ function fieldIndexGetArraySegment(fieldIndex) {
|
|
|
4221
4222
|
function fieldIndexGetDirectionalSegments(fieldIndex) {
|
|
4222
4223
|
return fieldIndex.fields.filter(s => s.kind !== 2 /* CONTAINS */);
|
|
4223
4224
|
}
|
|
4225
|
+
/**
|
|
4226
|
+
* Returns the order of the document key component for the given index.
|
|
4227
|
+
*
|
|
4228
|
+
* PORTING NOTE: This is only used in the Web IndexedDb implementation.
|
|
4229
|
+
*/
|
|
4230
|
+
function fieldIndexGetKeyOrder(fieldIndex) {
|
|
4231
|
+
const directionalSegments = fieldIndexGetDirectionalSegments(fieldIndex);
|
|
4232
|
+
return directionalSegments.length === 0
|
|
4233
|
+
? 0 /* ASCENDING */
|
|
4234
|
+
: directionalSegments[directionalSegments.length - 1].kind;
|
|
4235
|
+
}
|
|
4224
4236
|
/** Returns a debug representation of the field index */
|
|
4225
4237
|
function fieldIndexToString(fieldIndex) {
|
|
4226
4238
|
return `id=${fieldIndex.indexId}|cg=${fieldIndex.collectionGroup}|f=${fieldIndex.fields.map(f => `${f.fieldPath}:${f.kind}`).join(',')}`;
|
|
@@ -4521,58 +4533,15 @@ function targetGetLowerBound(target, fieldIndex) {
|
|
|
4521
4533
|
// For each segment, retrieve a lower bound if there is a suitable filter or
|
|
4522
4534
|
// startAt.
|
|
4523
4535
|
for (const segment of fieldIndexGetDirectionalSegments(fieldIndex)) {
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
let filterValue = undefined;
|
|
4529
|
-
let filterInclusive = true;
|
|
4530
|
-
switch (fieldFilter.op) {
|
|
4531
|
-
case "<" /* LESS_THAN */:
|
|
4532
|
-
case "<=" /* LESS_THAN_OR_EQUAL */:
|
|
4533
|
-
filterValue = valuesGetLowerBound(fieldFilter.value);
|
|
4534
|
-
break;
|
|
4535
|
-
case "==" /* EQUAL */:
|
|
4536
|
-
case "in" /* IN */:
|
|
4537
|
-
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
4538
|
-
filterValue = fieldFilter.value;
|
|
4539
|
-
break;
|
|
4540
|
-
case ">" /* GREATER_THAN */:
|
|
4541
|
-
filterValue = fieldFilter.value;
|
|
4542
|
-
filterInclusive = false;
|
|
4543
|
-
break;
|
|
4544
|
-
case "!=" /* NOT_EQUAL */:
|
|
4545
|
-
case "not-in" /* NOT_IN */:
|
|
4546
|
-
filterValue = MIN_VALUE;
|
|
4547
|
-
break;
|
|
4548
|
-
// Remaining filters cannot be used as lower bounds.
|
|
4549
|
-
}
|
|
4550
|
-
if (valuesMax(segmentValue, filterValue) === filterValue) {
|
|
4551
|
-
segmentValue = filterValue;
|
|
4552
|
-
segmentInclusive = filterInclusive;
|
|
4553
|
-
}
|
|
4554
|
-
}
|
|
4555
|
-
// If there is a startAt bound, compare the values against the existing
|
|
4556
|
-
// boundary to see if we can narrow the scope.
|
|
4557
|
-
if (target.startAt !== null) {
|
|
4558
|
-
for (let i = 0; i < target.orderBy.length; ++i) {
|
|
4559
|
-
const orderBy = target.orderBy[i];
|
|
4560
|
-
if (orderBy.field.isEqual(segment.fieldPath)) {
|
|
4561
|
-
const cursorValue = target.startAt.position[i];
|
|
4562
|
-
if (valuesMax(segmentValue, cursorValue) === cursorValue) {
|
|
4563
|
-
segmentValue = cursorValue;
|
|
4564
|
-
segmentInclusive = target.startAt.inclusive;
|
|
4565
|
-
}
|
|
4566
|
-
break;
|
|
4567
|
-
}
|
|
4568
|
-
}
|
|
4569
|
-
}
|
|
4570
|
-
if (segmentValue === undefined) {
|
|
4536
|
+
const segmentBound = segment.kind === 0 /* ASCENDING */
|
|
4537
|
+
? targetGetLowerBoundForField(target, segment.fieldPath, target.startAt)
|
|
4538
|
+
: targetGetUpperBoundForField(target, segment.fieldPath, target.startAt);
|
|
4539
|
+
if (!segmentBound.value) {
|
|
4571
4540
|
// No lower bound exists
|
|
4572
4541
|
return null;
|
|
4573
4542
|
}
|
|
4574
|
-
values.push(
|
|
4575
|
-
inclusive && (inclusive =
|
|
4543
|
+
values.push(segmentBound.value);
|
|
4544
|
+
inclusive && (inclusive = segmentBound.inclusive);
|
|
4576
4545
|
}
|
|
4577
4546
|
return new Bound(values, inclusive);
|
|
4578
4547
|
}
|
|
@@ -4587,62 +4556,125 @@ function targetGetUpperBound(target, fieldIndex) {
|
|
|
4587
4556
|
// For each segment, retrieve an upper bound if there is a suitable filter or
|
|
4588
4557
|
// endAt.
|
|
4589
4558
|
for (const segment of fieldIndexGetDirectionalSegments(fieldIndex)) {
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
let filterValue = undefined;
|
|
4595
|
-
let filterInclusive = true;
|
|
4596
|
-
switch (fieldFilter.op) {
|
|
4597
|
-
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
4598
|
-
case ">" /* GREATER_THAN */:
|
|
4599
|
-
filterValue = valuesGetUpperBound(fieldFilter.value);
|
|
4600
|
-
filterInclusive = false;
|
|
4601
|
-
break;
|
|
4602
|
-
case "==" /* EQUAL */:
|
|
4603
|
-
case "in" /* IN */:
|
|
4604
|
-
case "<=" /* LESS_THAN_OR_EQUAL */:
|
|
4605
|
-
filterValue = fieldFilter.value;
|
|
4606
|
-
break;
|
|
4607
|
-
case "<" /* LESS_THAN */:
|
|
4608
|
-
filterValue = fieldFilter.value;
|
|
4609
|
-
filterInclusive = false;
|
|
4610
|
-
break;
|
|
4611
|
-
case "!=" /* NOT_EQUAL */:
|
|
4612
|
-
case "not-in" /* NOT_IN */:
|
|
4613
|
-
filterValue = MAX_VALUE;
|
|
4614
|
-
break;
|
|
4615
|
-
// Remaining filters cannot be used as upper bounds.
|
|
4616
|
-
}
|
|
4617
|
-
if (valuesMin(segmentValue, filterValue) === filterValue) {
|
|
4618
|
-
segmentValue = filterValue;
|
|
4619
|
-
segmentInclusive = filterInclusive;
|
|
4620
|
-
}
|
|
4621
|
-
}
|
|
4622
|
-
// If there is a endAt bound, compare the values against the existing
|
|
4623
|
-
// boundary to see if we can narrow the scope.
|
|
4624
|
-
if (target.endAt !== null) {
|
|
4625
|
-
for (let i = 0; i < target.orderBy.length; ++i) {
|
|
4626
|
-
const orderBy = target.orderBy[i];
|
|
4627
|
-
if (orderBy.field.isEqual(segment.fieldPath)) {
|
|
4628
|
-
const cursorValue = target.endAt.position[i];
|
|
4629
|
-
if (valuesMin(segmentValue, cursorValue) === cursorValue) {
|
|
4630
|
-
segmentValue = cursorValue;
|
|
4631
|
-
segmentInclusive = target.endAt.inclusive;
|
|
4632
|
-
}
|
|
4633
|
-
break;
|
|
4634
|
-
}
|
|
4635
|
-
}
|
|
4636
|
-
}
|
|
4637
|
-
if (segmentValue === undefined) {
|
|
4559
|
+
const segmentBound = segment.kind === 0 /* ASCENDING */
|
|
4560
|
+
? targetGetUpperBoundForField(target, segment.fieldPath, target.endAt)
|
|
4561
|
+
: targetGetLowerBoundForField(target, segment.fieldPath, target.endAt);
|
|
4562
|
+
if (!segmentBound.value) {
|
|
4638
4563
|
// No upper bound exists
|
|
4639
4564
|
return null;
|
|
4640
4565
|
}
|
|
4641
|
-
values.push(
|
|
4642
|
-
inclusive && (inclusive =
|
|
4566
|
+
values.push(segmentBound.value);
|
|
4567
|
+
inclusive && (inclusive = segmentBound.inclusive);
|
|
4643
4568
|
}
|
|
4644
4569
|
return new Bound(values, inclusive);
|
|
4645
4570
|
}
|
|
4571
|
+
/**
|
|
4572
|
+
* Returns the value to use as the lower bound for ascending index segment at
|
|
4573
|
+
* the provided `fieldPath` (or the upper bound for an descending segment).
|
|
4574
|
+
*/
|
|
4575
|
+
function targetGetLowerBoundForField(target, fieldPath, bound) {
|
|
4576
|
+
let value = undefined;
|
|
4577
|
+
let inclusive = true;
|
|
4578
|
+
// Process all filters to find a value for the current field segment
|
|
4579
|
+
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
|
|
4580
|
+
let filterValue = undefined;
|
|
4581
|
+
let filterInclusive = true;
|
|
4582
|
+
switch (fieldFilter.op) {
|
|
4583
|
+
case "<" /* LESS_THAN */:
|
|
4584
|
+
case "<=" /* LESS_THAN_OR_EQUAL */:
|
|
4585
|
+
filterValue = valuesGetLowerBound(fieldFilter.value);
|
|
4586
|
+
break;
|
|
4587
|
+
case "==" /* EQUAL */:
|
|
4588
|
+
case "in" /* IN */:
|
|
4589
|
+
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
4590
|
+
filterValue = fieldFilter.value;
|
|
4591
|
+
break;
|
|
4592
|
+
case ">" /* GREATER_THAN */:
|
|
4593
|
+
filterValue = fieldFilter.value;
|
|
4594
|
+
filterInclusive = false;
|
|
4595
|
+
break;
|
|
4596
|
+
case "!=" /* NOT_EQUAL */:
|
|
4597
|
+
case "not-in" /* NOT_IN */:
|
|
4598
|
+
filterValue = MIN_VALUE;
|
|
4599
|
+
break;
|
|
4600
|
+
// Remaining filters cannot be used as lower bounds.
|
|
4601
|
+
}
|
|
4602
|
+
if (valuesMax(value, filterValue) === filterValue) {
|
|
4603
|
+
value = filterValue;
|
|
4604
|
+
inclusive = filterInclusive;
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
// If there is an additional bound, compare the values against the existing
|
|
4608
|
+
// range to see if we can narrow the scope.
|
|
4609
|
+
if (bound !== null) {
|
|
4610
|
+
for (let i = 0; i < target.orderBy.length; ++i) {
|
|
4611
|
+
const orderBy = target.orderBy[i];
|
|
4612
|
+
if (orderBy.field.isEqual(fieldPath)) {
|
|
4613
|
+
const cursorValue = bound.position[i];
|
|
4614
|
+
if (valuesMax(value, cursorValue) === cursorValue) {
|
|
4615
|
+
value = cursorValue;
|
|
4616
|
+
inclusive = bound.inclusive;
|
|
4617
|
+
}
|
|
4618
|
+
break;
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
return { value, inclusive };
|
|
4623
|
+
}
|
|
4624
|
+
/**
|
|
4625
|
+
* Returns the value to use as the upper bound for ascending index segment at
|
|
4626
|
+
* the provided `fieldPath` (or the lower bound for an descending segment).
|
|
4627
|
+
*/
|
|
4628
|
+
function targetGetUpperBoundForField(target, fieldPath, bound) {
|
|
4629
|
+
let value = undefined;
|
|
4630
|
+
let inclusive = true;
|
|
4631
|
+
// Process all filters to find a value for the current field segment
|
|
4632
|
+
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
|
|
4633
|
+
let filterValue = undefined;
|
|
4634
|
+
let filterInclusive = true;
|
|
4635
|
+
switch (fieldFilter.op) {
|
|
4636
|
+
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
4637
|
+
case ">" /* GREATER_THAN */:
|
|
4638
|
+
filterValue = valuesGetUpperBound(fieldFilter.value);
|
|
4639
|
+
filterInclusive = false;
|
|
4640
|
+
break;
|
|
4641
|
+
case "==" /* EQUAL */:
|
|
4642
|
+
case "in" /* IN */:
|
|
4643
|
+
case "<=" /* LESS_THAN_OR_EQUAL */:
|
|
4644
|
+
filterValue = fieldFilter.value;
|
|
4645
|
+
break;
|
|
4646
|
+
case "<" /* LESS_THAN */:
|
|
4647
|
+
filterValue = fieldFilter.value;
|
|
4648
|
+
filterInclusive = false;
|
|
4649
|
+
break;
|
|
4650
|
+
case "!=" /* NOT_EQUAL */:
|
|
4651
|
+
case "not-in" /* NOT_IN */:
|
|
4652
|
+
filterValue = MAX_VALUE;
|
|
4653
|
+
break;
|
|
4654
|
+
// Remaining filters cannot be used as upper bounds.
|
|
4655
|
+
}
|
|
4656
|
+
if (valuesMin(value, filterValue) === filterValue) {
|
|
4657
|
+
value = filterValue;
|
|
4658
|
+
inclusive = filterInclusive;
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
// If there is an additional bound, compare the values against the existing
|
|
4662
|
+
// range to see if we can narrow the scope.
|
|
4663
|
+
if (bound !== null) {
|
|
4664
|
+
for (let i = 0; i < target.orderBy.length; ++i) {
|
|
4665
|
+
const orderBy = target.orderBy[i];
|
|
4666
|
+
if (orderBy.field.isEqual(fieldPath)) {
|
|
4667
|
+
const cursorValue = bound.position[i];
|
|
4668
|
+
if (valuesMin(value, cursorValue) === cursorValue) {
|
|
4669
|
+
value = cursorValue;
|
|
4670
|
+
inclusive = bound.inclusive;
|
|
4671
|
+
}
|
|
4672
|
+
break;
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
}
|
|
4676
|
+
return { value, inclusive };
|
|
4677
|
+
}
|
|
4646
4678
|
class Filter {
|
|
4647
4679
|
}
|
|
4648
4680
|
class FieldFilter extends Filter {
|
|
@@ -10046,8 +10078,9 @@ const EMPTY_VALUE = new Uint8Array(0);
|
|
|
10046
10078
|
* data as it supports multi-tab access.
|
|
10047
10079
|
*/
|
|
10048
10080
|
class IndexedDbIndexManager {
|
|
10049
|
-
constructor(user) {
|
|
10081
|
+
constructor(user, databaseId) {
|
|
10050
10082
|
this.user = user;
|
|
10083
|
+
this.databaseId = databaseId;
|
|
10051
10084
|
/**
|
|
10052
10085
|
* An in-memory copy of the index entries we've already written since the SDK
|
|
10053
10086
|
* launched. Used to avoid re-writing the same entry repeatedly.
|
|
@@ -10143,7 +10176,8 @@ class IndexedDbIndexManager {
|
|
|
10143
10176
|
return PersistencePromise.resolve(null);
|
|
10144
10177
|
}
|
|
10145
10178
|
else {
|
|
10146
|
-
let
|
|
10179
|
+
let existingKeys = documentKeySet();
|
|
10180
|
+
const result = [];
|
|
10147
10181
|
return PersistencePromise.forEach(indexes, (index, subTarget) => {
|
|
10148
10182
|
logDebug(LOG_TAG$f, `Using index ${fieldIndexToString(index)} to execute ${canonifyTarget(target)}`);
|
|
10149
10183
|
const arrayValues = targetGetArrayValues(subTarget, index);
|
|
@@ -10159,7 +10193,11 @@ class IndexedDbIndexManager {
|
|
|
10159
10193
|
.loadFirst(indexRange, target.limit)
|
|
10160
10194
|
.next(entries => {
|
|
10161
10195
|
entries.forEach(entry => {
|
|
10162
|
-
|
|
10196
|
+
const documentKey = DocumentKey.fromSegments(entry.documentKey);
|
|
10197
|
+
if (!existingKeys.has(documentKey)) {
|
|
10198
|
+
existingKeys = existingKeys.add(documentKey);
|
|
10199
|
+
result.push(documentKey);
|
|
10200
|
+
}
|
|
10163
10201
|
});
|
|
10164
10202
|
});
|
|
10165
10203
|
});
|
|
@@ -10258,6 +10296,15 @@ class IndexedDbIndexManager {
|
|
|
10258
10296
|
FirestoreIndexValueWriter.INSTANCE.writeIndexValue(value, encoder.forKind(0 /* ASCENDING */));
|
|
10259
10297
|
return encoder.encodedBytes();
|
|
10260
10298
|
}
|
|
10299
|
+
/**
|
|
10300
|
+
* Returns an encoded form of the document key that sorts based on the key
|
|
10301
|
+
* ordering of the field index.
|
|
10302
|
+
*/
|
|
10303
|
+
encodeDirectionalKey(fieldIndex, documentKey) {
|
|
10304
|
+
const encoder = new IndexByteEncoder();
|
|
10305
|
+
FirestoreIndexValueWriter.INSTANCE.writeIndexValue(refValue(this.databaseId, documentKey), encoder.forKind(fieldIndexGetKeyOrder(fieldIndex)));
|
|
10306
|
+
return encoder.encodedBytes();
|
|
10307
|
+
}
|
|
10261
10308
|
/**
|
|
10262
10309
|
* Encodes the given field values according to the specification in `target`.
|
|
10263
10310
|
* For IN queries, a list of possible values is returned.
|
|
@@ -10381,7 +10428,7 @@ class IndexedDbIndexManager {
|
|
|
10381
10428
|
return this.getExistingIndexEntries(transaction, key, fieldIndex).next(existingEntries => {
|
|
10382
10429
|
const newEntries = this.computeIndexEntries(doc, fieldIndex);
|
|
10383
10430
|
if (!existingEntries.isEqual(newEntries)) {
|
|
10384
|
-
return this.updateEntries(transaction, doc, existingEntries, newEntries);
|
|
10431
|
+
return this.updateEntries(transaction, doc, fieldIndex, existingEntries, newEntries);
|
|
10385
10432
|
}
|
|
10386
10433
|
return PersistencePromise.resolve();
|
|
10387
10434
|
});
|
|
@@ -10389,24 +10436,26 @@ class IndexedDbIndexManager {
|
|
|
10389
10436
|
});
|
|
10390
10437
|
});
|
|
10391
10438
|
}
|
|
10392
|
-
addIndexEntry(transaction, document, indexEntry) {
|
|
10439
|
+
addIndexEntry(transaction, document, fieldIndex, indexEntry) {
|
|
10393
10440
|
const indexEntries = indexEntriesStore(transaction);
|
|
10394
10441
|
return indexEntries.put({
|
|
10395
10442
|
indexId: indexEntry.indexId,
|
|
10396
10443
|
uid: this.uid,
|
|
10397
10444
|
arrayValue: indexEntry.arrayValue,
|
|
10398
10445
|
directionalValue: indexEntry.directionalValue,
|
|
10399
|
-
|
|
10446
|
+
orderedDocumentKey: this.encodeDirectionalKey(fieldIndex, document.key),
|
|
10447
|
+
documentKey: document.key.path.toArray()
|
|
10400
10448
|
});
|
|
10401
10449
|
}
|
|
10402
|
-
deleteIndexEntry(transaction, document, indexEntry) {
|
|
10450
|
+
deleteIndexEntry(transaction, document, fieldIndex, indexEntry) {
|
|
10403
10451
|
const indexEntries = indexEntriesStore(transaction);
|
|
10404
10452
|
return indexEntries.delete([
|
|
10405
10453
|
indexEntry.indexId,
|
|
10406
10454
|
this.uid,
|
|
10407
10455
|
indexEntry.arrayValue,
|
|
10408
10456
|
indexEntry.directionalValue,
|
|
10409
|
-
|
|
10457
|
+
this.encodeDirectionalKey(fieldIndex, document.key),
|
|
10458
|
+
document.key.path.toArray()
|
|
10410
10459
|
]);
|
|
10411
10460
|
}
|
|
10412
10461
|
getExistingIndexEntries(transaction, documentKey, fieldIndex) {
|
|
@@ -10418,7 +10467,7 @@ class IndexedDbIndexManager {
|
|
|
10418
10467
|
range: IDBKeyRange.only([
|
|
10419
10468
|
fieldIndex.indexId,
|
|
10420
10469
|
this.uid,
|
|
10421
|
-
|
|
10470
|
+
this.encodeDirectionalKey(fieldIndex, documentKey)
|
|
10422
10471
|
])
|
|
10423
10472
|
}, (_, entry) => {
|
|
10424
10473
|
results = results.add(new IndexEntry(fieldIndex.indexId, documentKey, entry.arrayValue, entry.directionalValue));
|
|
@@ -10451,15 +10500,15 @@ class IndexedDbIndexManager {
|
|
|
10451
10500
|
* that are no longer referenced in `newEntries` and adding all newly added
|
|
10452
10501
|
* entries.
|
|
10453
10502
|
*/
|
|
10454
|
-
updateEntries(transaction, document, existingEntries, newEntries) {
|
|
10503
|
+
updateEntries(transaction, document, fieldIndex, existingEntries, newEntries) {
|
|
10455
10504
|
logDebug(LOG_TAG$f, "Updating index entries for document '%s'", document.key);
|
|
10456
10505
|
const promises = [];
|
|
10457
10506
|
diffSortedSets(existingEntries, newEntries, indexEntryComparator,
|
|
10458
10507
|
/* onAdd= */ entry => {
|
|
10459
|
-
promises.push(this.addIndexEntry(transaction, document, entry));
|
|
10508
|
+
promises.push(this.addIndexEntry(transaction, document, fieldIndex, entry));
|
|
10460
10509
|
},
|
|
10461
10510
|
/* onRemove= */ entry => {
|
|
10462
|
-
promises.push(this.deleteIndexEntry(transaction, document, entry));
|
|
10511
|
+
promises.push(this.deleteIndexEntry(transaction, document, fieldIndex, entry));
|
|
10463
10512
|
});
|
|
10464
10513
|
return PersistencePromise.waitFor(promises);
|
|
10465
10514
|
}
|
|
@@ -10516,13 +10565,15 @@ class IndexedDbIndexManager {
|
|
|
10516
10565
|
this.uid,
|
|
10517
10566
|
bounds[i].arrayValue,
|
|
10518
10567
|
bounds[i].directionalValue,
|
|
10519
|
-
|
|
10568
|
+
EMPTY_VALUE,
|
|
10569
|
+
[]
|
|
10520
10570
|
], [
|
|
10521
10571
|
bounds[i + 1].indexId,
|
|
10522
10572
|
this.uid,
|
|
10523
10573
|
bounds[i + 1].arrayValue,
|
|
10524
10574
|
bounds[i + 1].directionalValue,
|
|
10525
|
-
|
|
10575
|
+
EMPTY_VALUE,
|
|
10576
|
+
[]
|
|
10526
10577
|
]));
|
|
10527
10578
|
}
|
|
10528
10579
|
return ranges;
|
|
@@ -13182,7 +13233,7 @@ class IndexedDbPersistence {
|
|
|
13182
13233
|
return this.remoteDocumentCache;
|
|
13183
13234
|
}
|
|
13184
13235
|
getIndexManager(user) {
|
|
13185
|
-
return new IndexedDbIndexManager(user);
|
|
13236
|
+
return new IndexedDbIndexManager(user, this.serializer.remoteSerializer.databaseId);
|
|
13186
13237
|
}
|
|
13187
13238
|
getDocumentOverlayCache(user) {
|
|
13188
13239
|
return IndexedDbDocumentOverlayCache.forUser(this.serializer, user);
|