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

[TypeScript] PipelineStage.Merge interface definition is wrong #11109

Closed
gabrie-allaigre opened this issue Dec 16, 2021 · 0 comments · Fixed by #11132
Closed

[TypeScript] PipelineStage.Merge interface definition is wrong #11109

gabrie-allaigre opened this issue Dec 16, 2021 · 0 comments · Fixed by #11132
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@gabrie-allaigre
Copy link

Hi,

Introduced in Mongoose 6.1.0 PipelineStage.Merge has wrong definition:

export interface Merge {
      /** [`$merge` reference](https://docs.mongodb.com/manual/reference/operator/aggregation/merge/) */
      $merge: {
        into: string | { db: string; coll: string }
        on?: string | string[]
        let?: Record<string, any>
        whenMatched?: 'replace' | 'keepExisting' | 'merge' | 'fail' | 'pipeline'
        whenNotMatched?: 'insert' | 'discard' | 'fail'
      }
    }

'pipeline' is not a string, but a real pipeline stage array, https://docs.mongodb.com/manual/reference/operator/aggregation/merge/

And must be updated with:

export interface Merge {
      /** [`$merge` reference](https://docs.mongodb.com/manual/reference/operator/aggregation/merge/) */
      $merge: {
        into: string | { db: string; coll: string }
        on?: string | string[]
        let?: Record<string, any>
        whenMatched?: 'replace' | 'keepExisting' | 'merge' | 'fail' | Extract<PipelineStage, PipelineStage.AddFields | PipelineStage.Set | PipelineStage.Project | PipelineStage.Unset | PipelineStage.ReplaceRoot | PipelineStage.ReplaceWith>[]
        whenNotMatched?: 'insert' | 'discard' | 'fail'
      }
    }

Thanks

@IslandRhythms IslandRhythms added the confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. label Dec 17, 2021
@vkarpov15 vkarpov15 added this to the 6.1.4 milestone Dec 20, 2021
@vkarpov15 vkarpov15 added the typescript Types or Types-test related issue / Pull Request label Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants