I have about 25k documents in a collection (codename 'Parties') which is structured like this:
{
"_id": ObjectId("..."),
"name": "Magic Show",
"funStuff": [
{
"date": new Date("2010-01-04T16:00:00+1100"),
"start": 5,
"finish": 5.5,
"symbol": "ABCD"
}, ...
]
}, ...
Each document has a child array called funStuff that contains roughly 11k items.
I need to compare all Parties.funStuff using the date as a match. For example:
- Get 2 random documents (x, y) from parties
- Map through x.funStuff and attempt to match a date with y.funStuff
- If match occurs update/upsert a new document ('PartiesCompared') that looks roughly like this:
{ parent: x._id, child: y.id, results: ... }
4. Go back to step 2 moving forward a day.
I've tried a few JS solutions find -> map -> save results, but it very slow and will take months(just under a year lol) to complete. I'm obviously doing it very wrong.