Skip to content

Commit 0698def

Browse files
committed
PR comments
1 parent b90c5e6 commit 0698def

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/InMemoryProvider.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ class InMemoryIndex extends DbIndexFTSFromRangeQueries {
542542
return Promise.resolve(compact(flatten(values)));
543543
}
544544

545+
/**
546+
* Removes item from index. For non-unique indices, a pair of index value and a primary key is required.
547+
* @param key a string, if it's a unique index, a pair of key value and a primary key, if it's a non-unique index
548+
* @param skipTransactionOnCreation
549+
* @returns
550+
*/
545551
public remove(
546552
key: string | { primaryKey: string; idxKey: string },
547553
skipTransactionOnCreation?: boolean
@@ -566,10 +572,10 @@ class InMemoryIndex extends DbIndexFTSFromRangeQueries {
566572
return idxItemPrimaryKeyVal !== key.primaryKey;
567573
});
568574

569-
// removed all items? remove the index tree node
575+
// if we removed all items, remove the index tree node.
570576
// otherwise, update the index value with the new array
571577
// sans the primary key item
572-
if (idxItemsWithoutItem?.length === 0) {
578+
if (idxItemsWithoutItem.length === 0) {
573579
this._indexTree.delete(key.idxKey);
574580
} else {
575581
this._indexTree.set(key.idxKey, idxItemsWithoutItem);
@@ -603,6 +609,7 @@ class InMemoryIndex extends DbIndexFTSFromRangeQueries {
603609
continue;
604610
}
605611

612+
// a hack to account for offset that b+tree library lacks
606613
if (skip > 0) {
607614
skip--;
608615
continue;

0 commit comments

Comments
 (0)