I have a large in-memory dataset on the client side, and need to quickly update records in a wide dataset (at most, about 50k records at a time). Right now, I have a loop that looks like this.
// looping over new data entry, then either updating or adding if the id isn't already present
data.forEach((d) => {
const current = collection.by('id', d.id);
if (current) {
Object.assign(current, d);
collection.update(current);
} else collection.insert(d);
});
This loop takes about 10 seconds on a fast pc for 50k records, which is about 20x as long as I can afford for it take in the larger app context. Any thoughts would be greatly appreciated.
Thank you!