Skip to content

Commit

Permalink
fix: undefined difference function
Browse files Browse the repository at this point in the history
  • Loading branch information
StorytellerCZ committed Jun 17, 2024
1 parent da5233c commit 91a4dda
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/client/ground.db.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,13 @@ Ground.Collection = class GroundCollection {
// Map each cursor id's into one flat array
const keepIds = arrayOfCursors.map((cursor) => cursor.map((doc) => strId(doc._id))).flat();
// Remove all other documents from the collection
difference(currentIds, keepIds).forEach((id) => {
const arrays = [currentIds, keepIds];
for (const id of arrays.reduce((a, b) => a.filter((c) => !b.includes(c)))) {
// Remove it from in memory
delete this._collection._docs._map[id];
// Remove it from storage
this.saveDocument({ _id: id }, true);
});
}

this.invalidate();
}
Expand Down

0 comments on commit 91a4dda

Please sign in to comment.