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

Export a Separate Type for PipelineStage Types Allowed in Facet Aggregation Sub-Pipelines #11150

Merged
merged 2 commits into from
Dec 30, 2021

Conversation

mhoc
Copy link
Contributor

@mhoc mhoc commented Dec 28, 2021

Summary

This is a typescript type-only change.

Currently, the type definition for each sub-pipeline within a { $facet: ... } aggregation pipeline stage is baked in to the overall definition of the Facet stage.

We've got a situation where we'd like to pass these sub-pipeline arrays around, ideally in a type-safe way. Currently, that requires a bit of boilerplate to keep typescript happy; with this change, we should just be able to say, for example:

import * as mongoose from "mongoose";

export function Query(resultsFacet: mongoose.FacetPipelineStage[]) {
  return db.myCollection.aggregate([{
    $facet: { results: resultsFacet },
  }]);
}

Happy to change the name of this type if FacetPipelineStage doesn't make sense.

Thank you for the great project 😀

@vkarpov15 vkarpov15 merged commit b0d525d into Automattic:master Dec 30, 2021
@vkarpov15 vkarpov15 added this to the 6.1.5 milestone Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants