Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database level aggregate() support #15118

Open
vkarpov15 opened this issue Dec 18, 2024 · 0 comments
Open

Database level aggregate() support #15118

vkarpov15 opened this issue Dec 18, 2024 · 0 comments
Labels
new feature This change adds new functionality, like a new method or class
Milestone

Comments

@vkarpov15
Copy link
Collaborator

Similar to db-level bulkWrite() that we added in 8.9

Discussed in #14953

Originally posted by yannispgs October 10, 2024
Hi !

I am trying to run an aggregation pipeline on one of my collection that has multiple stages. The purpose of it is to get an array of data, and then, depending on a condition, running (or not) another aggregation pipeline with this transformed data.

We already have an aggregation pipeline who does that by having a $facet as last stage, with one variable metrics that store all the documents as they are, and another variable tests that store the result of the second aggregation pipeline. This $facet pipeline only runs if certain conditions are met. That way, if the conditions are met, the second pipeline is run and we retrieve the results in both variables metrics and tests. Otherwise, we just return the output in the metrics variable.

The issue is that $facet load all the documents of every subpipeline in a single variable. My first pipeline can return dozens of thousands of results for some apps, thus triggering the error about the max size a single document can have (16MB).

To resolve that, I tried to run 2 aggregation pipelines sequentially, but I don't want to use a "temporary collection" to store the results of the first pipeline to put as input in the 2nd one (with $out or $merge). However, I did not find another way to do it with Mongoose. The $documents stage could work, but it is not supported by Mongoose...

Is there soemone who managed to achieve something similar ?

@vkarpov15 vkarpov15 added this to the 8.10 milestone Dec 18, 2024
@vkarpov15 vkarpov15 added the new feature This change adds new functionality, like a new method or class label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

No branches or pull requests

1 participant