@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.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.7-canary.
|
|
11
|
+
const version$1 = "3.4.7-canary.7a4e65cef";
|
|
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.10-canary.
|
|
64
|
+
const version = "9.6.10-canary.7a4e65cef";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* @license
|
|
@@ -1393,13 +1393,14 @@ const DbIndexEntryKeyPath = [
|
|
|
1393
1393
|
'uid',
|
|
1394
1394
|
'arrayValue',
|
|
1395
1395
|
'directionalValue',
|
|
1396
|
+
'orderedDocumentKey',
|
|
1396
1397
|
'documentKey'
|
|
1397
1398
|
];
|
|
1398
1399
|
const DbIndexEntryDocumentKeyIndex = 'documentKeyIndex';
|
|
1399
1400
|
const DbIndexEntryDocumentKeyIndexPath = [
|
|
1400
1401
|
'indexId',
|
|
1401
1402
|
'uid',
|
|
1402
|
-
'
|
|
1403
|
+
'orderedDocumentKey'
|
|
1403
1404
|
];
|
|
1404
1405
|
/** Name of the IndexedDb object store. */
|
|
1405
1406
|
const DbDocumentOverlayStore = 'documentOverlays';
|
|
@@ -4196,6 +4197,17 @@ function fieldIndexGetArraySegment(fieldIndex) {
|
|
|
4196
4197
|
function fieldIndexGetDirectionalSegments(fieldIndex) {
|
|
4197
4198
|
return fieldIndex.fields.filter(s => s.kind !== 2 /* CONTAINS */);
|
|
4198
4199
|
}
|
|
4200
|
+
/**
|
|
4201
|
+
* Returns the order of the document key component for the given index.
|
|
4202
|
+
*
|
|
4203
|
+
* PORTING NOTE: This is only used in the Web IndexedDb implementation.
|
|
4204
|
+
*/
|
|
4205
|
+
function fieldIndexGetKeyOrder(fieldIndex) {
|
|
4206
|
+
const directionalSegments = fieldIndexGetDirectionalSegments(fieldIndex);
|
|
4207
|
+
return directionalSegments.length === 0
|
|
4208
|
+
? 0 /* ASCENDING */
|
|
4209
|
+
: directionalSegments[directionalSegments.length - 1].kind;
|
|
4210
|
+
}
|
|
4199
4211
|
/** Returns a debug representation of the field index */
|
|
4200
4212
|
function fieldIndexToString(fieldIndex) {
|
|
4201
4213
|
return `id=${fieldIndex.indexId}|cg=${fieldIndex.collectionGroup}|f=${fieldIndex.fields.map(f => `${f.fieldPath}:${f.kind}`).join(',')}`;
|
|
@@ -4496,58 +4508,15 @@ function targetGetLowerBound(target, fieldIndex) {
|
|
|
4496
4508
|
// For each segment, retrieve a lower bound if there is a suitable filter or
|
|
4497
4509
|
// startAt.
|
|
4498
4510
|
for (const segment of fieldIndexGetDirectionalSegments(fieldIndex)) {
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
let filterValue = undefined;
|
|
4504
|
-
let filterInclusive = true;
|
|
4505
|
-
switch (fieldFilter.op) {
|
|
4506
|
-
case "<" /* LESS_THAN */:
|
|
4507
|
-
case "<=" /* LESS_THAN_OR_EQUAL */:
|
|
4508
|
-
filterValue = valuesGetLowerBound(fieldFilter.value);
|
|
4509
|
-
break;
|
|
4510
|
-
case "==" /* EQUAL */:
|
|
4511
|
-
case "in" /* IN */:
|
|
4512
|
-
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
4513
|
-
filterValue = fieldFilter.value;
|
|
4514
|
-
break;
|
|
4515
|
-
case ">" /* GREATER_THAN */:
|
|
4516
|
-
filterValue = fieldFilter.value;
|
|
4517
|
-
filterInclusive = false;
|
|
4518
|
-
break;
|
|
4519
|
-
case "!=" /* NOT_EQUAL */:
|
|
4520
|
-
case "not-in" /* NOT_IN */:
|
|
4521
|
-
filterValue = MIN_VALUE;
|
|
4522
|
-
break;
|
|
4523
|
-
// Remaining filters cannot be used as lower bounds.
|
|
4524
|
-
}
|
|
4525
|
-
if (valuesMax(segmentValue, filterValue) === filterValue) {
|
|
4526
|
-
segmentValue = filterValue;
|
|
4527
|
-
segmentInclusive = filterInclusive;
|
|
4528
|
-
}
|
|
4529
|
-
}
|
|
4530
|
-
// If there is a startAt bound, compare the values against the existing
|
|
4531
|
-
// boundary to see if we can narrow the scope.
|
|
4532
|
-
if (target.startAt !== null) {
|
|
4533
|
-
for (let i = 0; i < target.orderBy.length; ++i) {
|
|
4534
|
-
const orderBy = target.orderBy[i];
|
|
4535
|
-
if (orderBy.field.isEqual(segment.fieldPath)) {
|
|
4536
|
-
const cursorValue = target.startAt.position[i];
|
|
4537
|
-
if (valuesMax(segmentValue, cursorValue) === cursorValue) {
|
|
4538
|
-
segmentValue = cursorValue;
|
|
4539
|
-
segmentInclusive = target.startAt.inclusive;
|
|
4540
|
-
}
|
|
4541
|
-
break;
|
|
4542
|
-
}
|
|
4543
|
-
}
|
|
4544
|
-
}
|
|
4545
|
-
if (segmentValue === undefined) {
|
|
4511
|
+
const segmentBound = segment.kind === 0 /* ASCENDING */
|
|
4512
|
+
? targetGetLowerBoundForField(target, segment.fieldPath, target.startAt)
|
|
4513
|
+
: targetGetUpperBoundForField(target, segment.fieldPath, target.startAt);
|
|
4514
|
+
if (!segmentBound.value) {
|
|
4546
4515
|
// No lower bound exists
|
|
4547
4516
|
return null;
|
|
4548
4517
|
}
|
|
4549
|
-
values.push(
|
|
4550
|
-
inclusive && (inclusive =
|
|
4518
|
+
values.push(segmentBound.value);
|
|
4519
|
+
inclusive && (inclusive = segmentBound.inclusive);
|
|
4551
4520
|
}
|
|
4552
4521
|
return new Bound(values, inclusive);
|
|
4553
4522
|
}
|
|
@@ -4562,62 +4531,125 @@ function targetGetUpperBound(target, fieldIndex) {
|
|
|
4562
4531
|
// For each segment, retrieve an upper bound if there is a suitable filter or
|
|
4563
4532
|
// endAt.
|
|
4564
4533
|
for (const segment of fieldIndexGetDirectionalSegments(fieldIndex)) {
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
let filterValue = undefined;
|
|
4570
|
-
let filterInclusive = true;
|
|
4571
|
-
switch (fieldFilter.op) {
|
|
4572
|
-
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
4573
|
-
case ">" /* GREATER_THAN */:
|
|
4574
|
-
filterValue = valuesGetUpperBound(fieldFilter.value);
|
|
4575
|
-
filterInclusive = false;
|
|
4576
|
-
break;
|
|
4577
|
-
case "==" /* EQUAL */:
|
|
4578
|
-
case "in" /* IN */:
|
|
4579
|
-
case "<=" /* LESS_THAN_OR_EQUAL */:
|
|
4580
|
-
filterValue = fieldFilter.value;
|
|
4581
|
-
break;
|
|
4582
|
-
case "<" /* LESS_THAN */:
|
|
4583
|
-
filterValue = fieldFilter.value;
|
|
4584
|
-
filterInclusive = false;
|
|
4585
|
-
break;
|
|
4586
|
-
case "!=" /* NOT_EQUAL */:
|
|
4587
|
-
case "not-in" /* NOT_IN */:
|
|
4588
|
-
filterValue = MAX_VALUE;
|
|
4589
|
-
break;
|
|
4590
|
-
// Remaining filters cannot be used as upper bounds.
|
|
4591
|
-
}
|
|
4592
|
-
if (valuesMin(segmentValue, filterValue) === filterValue) {
|
|
4593
|
-
segmentValue = filterValue;
|
|
4594
|
-
segmentInclusive = filterInclusive;
|
|
4595
|
-
}
|
|
4596
|
-
}
|
|
4597
|
-
// If there is a endAt bound, compare the values against the existing
|
|
4598
|
-
// boundary to see if we can narrow the scope.
|
|
4599
|
-
if (target.endAt !== null) {
|
|
4600
|
-
for (let i = 0; i < target.orderBy.length; ++i) {
|
|
4601
|
-
const orderBy = target.orderBy[i];
|
|
4602
|
-
if (orderBy.field.isEqual(segment.fieldPath)) {
|
|
4603
|
-
const cursorValue = target.endAt.position[i];
|
|
4604
|
-
if (valuesMin(segmentValue, cursorValue) === cursorValue) {
|
|
4605
|
-
segmentValue = cursorValue;
|
|
4606
|
-
segmentInclusive = target.endAt.inclusive;
|
|
4607
|
-
}
|
|
4608
|
-
break;
|
|
4609
|
-
}
|
|
4610
|
-
}
|
|
4611
|
-
}
|
|
4612
|
-
if (segmentValue === undefined) {
|
|
4534
|
+
const segmentBound = segment.kind === 0 /* ASCENDING */
|
|
4535
|
+
? targetGetUpperBoundForField(target, segment.fieldPath, target.endAt)
|
|
4536
|
+
: targetGetLowerBoundForField(target, segment.fieldPath, target.endAt);
|
|
4537
|
+
if (!segmentBound.value) {
|
|
4613
4538
|
// No upper bound exists
|
|
4614
4539
|
return null;
|
|
4615
4540
|
}
|
|
4616
|
-
values.push(
|
|
4617
|
-
inclusive && (inclusive =
|
|
4541
|
+
values.push(segmentBound.value);
|
|
4542
|
+
inclusive && (inclusive = segmentBound.inclusive);
|
|
4618
4543
|
}
|
|
4619
4544
|
return new Bound(values, inclusive);
|
|
4620
4545
|
}
|
|
4546
|
+
/**
|
|
4547
|
+
* Returns the value to use as the lower bound for ascending index segment at
|
|
4548
|
+
* the provided `fieldPath` (or the upper bound for an descending segment).
|
|
4549
|
+
*/
|
|
4550
|
+
function targetGetLowerBoundForField(target, fieldPath, bound) {
|
|
4551
|
+
let value = undefined;
|
|
4552
|
+
let inclusive = true;
|
|
4553
|
+
// Process all filters to find a value for the current field segment
|
|
4554
|
+
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
|
|
4555
|
+
let filterValue = undefined;
|
|
4556
|
+
let filterInclusive = true;
|
|
4557
|
+
switch (fieldFilter.op) {
|
|
4558
|
+
case "<" /* LESS_THAN */:
|
|
4559
|
+
case "<=" /* LESS_THAN_OR_EQUAL */:
|
|
4560
|
+
filterValue = valuesGetLowerBound(fieldFilter.value);
|
|
4561
|
+
break;
|
|
4562
|
+
case "==" /* EQUAL */:
|
|
4563
|
+
case "in" /* IN */:
|
|
4564
|
+
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
4565
|
+
filterValue = fieldFilter.value;
|
|
4566
|
+
break;
|
|
4567
|
+
case ">" /* GREATER_THAN */:
|
|
4568
|
+
filterValue = fieldFilter.value;
|
|
4569
|
+
filterInclusive = false;
|
|
4570
|
+
break;
|
|
4571
|
+
case "!=" /* NOT_EQUAL */:
|
|
4572
|
+
case "not-in" /* NOT_IN */:
|
|
4573
|
+
filterValue = MIN_VALUE;
|
|
4574
|
+
break;
|
|
4575
|
+
// Remaining filters cannot be used as lower bounds.
|
|
4576
|
+
}
|
|
4577
|
+
if (valuesMax(value, filterValue) === filterValue) {
|
|
4578
|
+
value = filterValue;
|
|
4579
|
+
inclusive = filterInclusive;
|
|
4580
|
+
}
|
|
4581
|
+
}
|
|
4582
|
+
// If there is an additional bound, compare the values against the existing
|
|
4583
|
+
// range to see if we can narrow the scope.
|
|
4584
|
+
if (bound !== null) {
|
|
4585
|
+
for (let i = 0; i < target.orderBy.length; ++i) {
|
|
4586
|
+
const orderBy = target.orderBy[i];
|
|
4587
|
+
if (orderBy.field.isEqual(fieldPath)) {
|
|
4588
|
+
const cursorValue = bound.position[i];
|
|
4589
|
+
if (valuesMax(value, cursorValue) === cursorValue) {
|
|
4590
|
+
value = cursorValue;
|
|
4591
|
+
inclusive = bound.inclusive;
|
|
4592
|
+
}
|
|
4593
|
+
break;
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
return { value, inclusive };
|
|
4598
|
+
}
|
|
4599
|
+
/**
|
|
4600
|
+
* Returns the value to use as the upper bound for ascending index segment at
|
|
4601
|
+
* the provided `fieldPath` (or the lower bound for an descending segment).
|
|
4602
|
+
*/
|
|
4603
|
+
function targetGetUpperBoundForField(target, fieldPath, bound) {
|
|
4604
|
+
let value = undefined;
|
|
4605
|
+
let inclusive = true;
|
|
4606
|
+
// Process all filters to find a value for the current field segment
|
|
4607
|
+
for (const fieldFilter of targetGetFieldFiltersForPath(target, fieldPath)) {
|
|
4608
|
+
let filterValue = undefined;
|
|
4609
|
+
let filterInclusive = true;
|
|
4610
|
+
switch (fieldFilter.op) {
|
|
4611
|
+
case ">=" /* GREATER_THAN_OR_EQUAL */:
|
|
4612
|
+
case ">" /* GREATER_THAN */:
|
|
4613
|
+
filterValue = valuesGetUpperBound(fieldFilter.value);
|
|
4614
|
+
filterInclusive = false;
|
|
4615
|
+
break;
|
|
4616
|
+
case "==" /* EQUAL */:
|
|
4617
|
+
case "in" /* IN */:
|
|
4618
|
+
case "<=" /* LESS_THAN_OR_EQUAL */:
|
|
4619
|
+
filterValue = fieldFilter.value;
|
|
4620
|
+
break;
|
|
4621
|
+
case "<" /* LESS_THAN */:
|
|
4622
|
+
filterValue = fieldFilter.value;
|
|
4623
|
+
filterInclusive = false;
|
|
4624
|
+
break;
|
|
4625
|
+
case "!=" /* NOT_EQUAL */:
|
|
4626
|
+
case "not-in" /* NOT_IN */:
|
|
4627
|
+
filterValue = MAX_VALUE;
|
|
4628
|
+
break;
|
|
4629
|
+
// Remaining filters cannot be used as upper bounds.
|
|
4630
|
+
}
|
|
4631
|
+
if (valuesMin(value, filterValue) === filterValue) {
|
|
4632
|
+
value = filterValue;
|
|
4633
|
+
inclusive = filterInclusive;
|
|
4634
|
+
}
|
|
4635
|
+
}
|
|
4636
|
+
// If there is an additional bound, compare the values against the existing
|
|
4637
|
+
// range to see if we can narrow the scope.
|
|
4638
|
+
if (bound !== null) {
|
|
4639
|
+
for (let i = 0; i < target.orderBy.length; ++i) {
|
|
4640
|
+
const orderBy = target.orderBy[i];
|
|
4641
|
+
if (orderBy.field.isEqual(fieldPath)) {
|
|
4642
|
+
const cursorValue = bound.position[i];
|
|
4643
|
+
if (valuesMin(value, cursorValue) === cursorValue) {
|
|
4644
|
+
value = cursorValue;
|
|
4645
|
+
inclusive = bound.inclusive;
|
|
4646
|
+
}
|
|
4647
|
+
break;
|
|
4648
|
+
}
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
return { value, inclusive };
|
|
4652
|
+
}
|
|
4621
4653
|
class Filter {
|
|
4622
4654
|
}
|
|
4623
4655
|
class FieldFilter extends Filter {
|
|
@@ -10021,8 +10053,9 @@ const EMPTY_VALUE = new Uint8Array(0);
|
|
|
10021
10053
|
* data as it supports multi-tab access.
|
|
10022
10054
|
*/
|
|
10023
10055
|
class IndexedDbIndexManager {
|
|
10024
|
-
constructor(user) {
|
|
10056
|
+
constructor(user, databaseId) {
|
|
10025
10057
|
this.user = user;
|
|
10058
|
+
this.databaseId = databaseId;
|
|
10026
10059
|
/**
|
|
10027
10060
|
* An in-memory copy of the index entries we've already written since the SDK
|
|
10028
10061
|
* launched. Used to avoid re-writing the same entry repeatedly.
|
|
@@ -10118,7 +10151,8 @@ class IndexedDbIndexManager {
|
|
|
10118
10151
|
return PersistencePromise.resolve(null);
|
|
10119
10152
|
}
|
|
10120
10153
|
else {
|
|
10121
|
-
let
|
|
10154
|
+
let existingKeys = documentKeySet();
|
|
10155
|
+
const result = [];
|
|
10122
10156
|
return PersistencePromise.forEach(indexes, (index, subTarget) => {
|
|
10123
10157
|
logDebug(LOG_TAG$f, `Using index ${fieldIndexToString(index)} to execute ${canonifyTarget(target)}`);
|
|
10124
10158
|
const arrayValues = targetGetArrayValues(subTarget, index);
|
|
@@ -10134,7 +10168,11 @@ class IndexedDbIndexManager {
|
|
|
10134
10168
|
.loadFirst(indexRange, target.limit)
|
|
10135
10169
|
.next(entries => {
|
|
10136
10170
|
entries.forEach(entry => {
|
|
10137
|
-
|
|
10171
|
+
const documentKey = DocumentKey.fromSegments(entry.documentKey);
|
|
10172
|
+
if (!existingKeys.has(documentKey)) {
|
|
10173
|
+
existingKeys = existingKeys.add(documentKey);
|
|
10174
|
+
result.push(documentKey);
|
|
10175
|
+
}
|
|
10138
10176
|
});
|
|
10139
10177
|
});
|
|
10140
10178
|
});
|
|
@@ -10233,6 +10271,15 @@ class IndexedDbIndexManager {
|
|
|
10233
10271
|
FirestoreIndexValueWriter.INSTANCE.writeIndexValue(value, encoder.forKind(0 /* ASCENDING */));
|
|
10234
10272
|
return encoder.encodedBytes();
|
|
10235
10273
|
}
|
|
10274
|
+
/**
|
|
10275
|
+
* Returns an encoded form of the document key that sorts based on the key
|
|
10276
|
+
* ordering of the field index.
|
|
10277
|
+
*/
|
|
10278
|
+
encodeDirectionalKey(fieldIndex, documentKey) {
|
|
10279
|
+
const encoder = new IndexByteEncoder();
|
|
10280
|
+
FirestoreIndexValueWriter.INSTANCE.writeIndexValue(refValue(this.databaseId, documentKey), encoder.forKind(fieldIndexGetKeyOrder(fieldIndex)));
|
|
10281
|
+
return encoder.encodedBytes();
|
|
10282
|
+
}
|
|
10236
10283
|
/**
|
|
10237
10284
|
* Encodes the given field values according to the specification in `target`.
|
|
10238
10285
|
* For IN queries, a list of possible values is returned.
|
|
@@ -10356,7 +10403,7 @@ class IndexedDbIndexManager {
|
|
|
10356
10403
|
return this.getExistingIndexEntries(transaction, key, fieldIndex).next(existingEntries => {
|
|
10357
10404
|
const newEntries = this.computeIndexEntries(doc, fieldIndex);
|
|
10358
10405
|
if (!existingEntries.isEqual(newEntries)) {
|
|
10359
|
-
return this.updateEntries(transaction, doc, existingEntries, newEntries);
|
|
10406
|
+
return this.updateEntries(transaction, doc, fieldIndex, existingEntries, newEntries);
|
|
10360
10407
|
}
|
|
10361
10408
|
return PersistencePromise.resolve();
|
|
10362
10409
|
});
|
|
@@ -10364,24 +10411,26 @@ class IndexedDbIndexManager {
|
|
|
10364
10411
|
});
|
|
10365
10412
|
});
|
|
10366
10413
|
}
|
|
10367
|
-
addIndexEntry(transaction, document, indexEntry) {
|
|
10414
|
+
addIndexEntry(transaction, document, fieldIndex, indexEntry) {
|
|
10368
10415
|
const indexEntries = indexEntriesStore(transaction);
|
|
10369
10416
|
return indexEntries.put({
|
|
10370
10417
|
indexId: indexEntry.indexId,
|
|
10371
10418
|
uid: this.uid,
|
|
10372
10419
|
arrayValue: indexEntry.arrayValue,
|
|
10373
10420
|
directionalValue: indexEntry.directionalValue,
|
|
10374
|
-
|
|
10421
|
+
orderedDocumentKey: this.encodeDirectionalKey(fieldIndex, document.key),
|
|
10422
|
+
documentKey: document.key.path.toArray()
|
|
10375
10423
|
});
|
|
10376
10424
|
}
|
|
10377
|
-
deleteIndexEntry(transaction, document, indexEntry) {
|
|
10425
|
+
deleteIndexEntry(transaction, document, fieldIndex, indexEntry) {
|
|
10378
10426
|
const indexEntries = indexEntriesStore(transaction);
|
|
10379
10427
|
return indexEntries.delete([
|
|
10380
10428
|
indexEntry.indexId,
|
|
10381
10429
|
this.uid,
|
|
10382
10430
|
indexEntry.arrayValue,
|
|
10383
10431
|
indexEntry.directionalValue,
|
|
10384
|
-
|
|
10432
|
+
this.encodeDirectionalKey(fieldIndex, document.key),
|
|
10433
|
+
document.key.path.toArray()
|
|
10385
10434
|
]);
|
|
10386
10435
|
}
|
|
10387
10436
|
getExistingIndexEntries(transaction, documentKey, fieldIndex) {
|
|
@@ -10393,7 +10442,7 @@ class IndexedDbIndexManager {
|
|
|
10393
10442
|
range: IDBKeyRange.only([
|
|
10394
10443
|
fieldIndex.indexId,
|
|
10395
10444
|
this.uid,
|
|
10396
|
-
|
|
10445
|
+
this.encodeDirectionalKey(fieldIndex, documentKey)
|
|
10397
10446
|
])
|
|
10398
10447
|
}, (_, entry) => {
|
|
10399
10448
|
results = results.add(new IndexEntry(fieldIndex.indexId, documentKey, entry.arrayValue, entry.directionalValue));
|
|
@@ -10426,15 +10475,15 @@ class IndexedDbIndexManager {
|
|
|
10426
10475
|
* that are no longer referenced in `newEntries` and adding all newly added
|
|
10427
10476
|
* entries.
|
|
10428
10477
|
*/
|
|
10429
|
-
updateEntries(transaction, document, existingEntries, newEntries) {
|
|
10478
|
+
updateEntries(transaction, document, fieldIndex, existingEntries, newEntries) {
|
|
10430
10479
|
logDebug(LOG_TAG$f, "Updating index entries for document '%s'", document.key);
|
|
10431
10480
|
const promises = [];
|
|
10432
10481
|
diffSortedSets(existingEntries, newEntries, indexEntryComparator,
|
|
10433
10482
|
/* onAdd= */ entry => {
|
|
10434
|
-
promises.push(this.addIndexEntry(transaction, document, entry));
|
|
10483
|
+
promises.push(this.addIndexEntry(transaction, document, fieldIndex, entry));
|
|
10435
10484
|
},
|
|
10436
10485
|
/* onRemove= */ entry => {
|
|
10437
|
-
promises.push(this.deleteIndexEntry(transaction, document, entry));
|
|
10486
|
+
promises.push(this.deleteIndexEntry(transaction, document, fieldIndex, entry));
|
|
10438
10487
|
});
|
|
10439
10488
|
return PersistencePromise.waitFor(promises);
|
|
10440
10489
|
}
|
|
@@ -10491,13 +10540,15 @@ class IndexedDbIndexManager {
|
|
|
10491
10540
|
this.uid,
|
|
10492
10541
|
bounds[i].arrayValue,
|
|
10493
10542
|
bounds[i].directionalValue,
|
|
10494
|
-
|
|
10543
|
+
EMPTY_VALUE,
|
|
10544
|
+
[]
|
|
10495
10545
|
], [
|
|
10496
10546
|
bounds[i + 1].indexId,
|
|
10497
10547
|
this.uid,
|
|
10498
10548
|
bounds[i + 1].arrayValue,
|
|
10499
10549
|
bounds[i + 1].directionalValue,
|
|
10500
|
-
|
|
10550
|
+
EMPTY_VALUE,
|
|
10551
|
+
[]
|
|
10501
10552
|
]));
|
|
10502
10553
|
}
|
|
10503
10554
|
return ranges;
|
|
@@ -13157,7 +13208,7 @@ class IndexedDbPersistence {
|
|
|
13157
13208
|
return this.remoteDocumentCache;
|
|
13158
13209
|
}
|
|
13159
13210
|
getIndexManager(user) {
|
|
13160
|
-
return new IndexedDbIndexManager(user);
|
|
13211
|
+
return new IndexedDbIndexManager(user, this.serializer.remoteSerializer.databaseId);
|
|
13161
13212
|
}
|
|
13162
13213
|
getDocumentOverlayCache(user) {
|
|
13163
13214
|
return IndexedDbDocumentOverlayCache.forUser(this.serializer, user);
|