I'm building a filter page with Craft and Sprig. The goal is to show the amount of products for each filter. So for example if we want to filter on color we show 2 checkboxes "Red" and "Green" and I want to show the number of related products for the Red items and the related number for the green number.
The problem I'm currently encountering is that I calculate the amount of results by adding a
andRelatedTo parameter to my main query. This works perfect for the first checkbox but since the second checkbox adds another
andRelatedTo parameter and the previous one is still there the number will always be 0 because none of the products are both "Red" and "Green".
Is there a way to create a deep copy of the original main query so I can reuse it without polluting it with the count of the available options?