@@ -542,6 +542,12 @@ class InMemoryIndex extends DbIndexFTSFromRangeQueries {
542
542
return Promise . resolve ( compact ( flatten ( values ) ) ) ;
543
543
}
544
544
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
+ */
545
551
public remove (
546
552
key : string | { primaryKey : string ; idxKey : string } ,
547
553
skipTransactionOnCreation ?: boolean
@@ -566,10 +572,10 @@ class InMemoryIndex extends DbIndexFTSFromRangeQueries {
566
572
return idxItemPrimaryKeyVal !== key . primaryKey ;
567
573
} ) ;
568
574
569
- // removed all items? remove the index tree node
575
+ // if we removed all items, remove the index tree node.
570
576
// otherwise, update the index value with the new array
571
577
// sans the primary key item
572
- if ( idxItemsWithoutItem ? .length === 0 ) {
578
+ if ( idxItemsWithoutItem . length === 0 ) {
573
579
this . _indexTree . delete ( key . idxKey ) ;
574
580
} else {
575
581
this . _indexTree . set ( key . idxKey , idxItemsWithoutItem ) ;
@@ -603,6 +609,7 @@ class InMemoryIndex extends DbIndexFTSFromRangeQueries {
603
609
continue ;
604
610
}
605
611
612
+ // a hack to account for offset that b+tree library lacks
606
613
if ( skip > 0 ) {
607
614
skip -- ;
608
615
continue ;
0 commit comments