I’m trying to run a Firestore query to remove duplicates.
The problem is: there are too many documents in the result, so I get a “ERROR: Maximum call stack size exceeded”.
What I’m trying to do:
- Query Firestore with a simple where.
{"structuredQuery": {"where": {"fieldFilter": {"field": {"fieldPath": "source"},"op": "EQUAL", "value": {"stringValue": "ServiceName}}}, "from": [{"collectionId":"deals"}]}}
- Run a Function to select duplicates
const seen = new Set();
return items.filter(i => {
if (seen.has(i.json.id)) return true;
seen.add(i.json.id);
return false;
});
- Run a Firestore node deleting the duplicated items.
Any idea how can I get this done for large queries?
Unfortunately in the beginning of my project I didn’t check for duplicates before submiting to Firebase and I ended up with a database full of dups.
Thanks.