Skip to content

Commit

Permalink
fix: remove id from index after removal
Browse files Browse the repository at this point in the history
resolves #607
  • Loading branch information
gotgameio authored and maxnowack committed Mar 23, 2024
1 parent a84459d commit 1f75de8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/signaldb/src/Collection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
this.executeInDebugMode(callstack => this.emit('_debug.removeOne', callstack, selector))
if (item == null) return 0
this.memory().splice(index, 1)
this.idIndex.delete(serializeValue(item.id))
this.rebuildIndices()
this.emit('removed', item)
return 1
Expand All @@ -424,6 +425,7 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
const index = this.memory().findIndex(doc => doc === item)
if (index === -1) throw new Error('Cannot resolve index for item')
this.memory().splice(index, 1)
this.idIndex.delete(serializeValue(item.id))
this.rebuildIndices()
})

Expand Down

0 comments on commit 1f75de8

Please sign in to comment.