Lets say I have a collection of documents like:
[
{ createdAt: 1688383980100, win: true }
{ createdAt: 1688383980200, win: false }
{ createdAt: 1688383980300, win: true }
{ createdAt: 1688383980400, win: true }
{ createdAt: 1688383980500, win: false }
]
How can I get the maximum win streak?
I managed to get it via $group and $accumulator with custom JS functions.
But Digital Ocean does not allow JS on their mongo DB servers.
Then I spent almost a day trying many pipeline alternatives, no success.
Any tips or pointers are super welcome! Thanks in advance!
Checking performance over a collection of about 200,000 records, my solution with the string splitting takes about 6s to complete, and the SO reply takes about 1s so it’s a LOT more performant.
They both arrive at the same answer, which is at least something for my solution!