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

types: $addFields is broken with nested fields #12089

Closed
2 tasks done
AbdelrahmanHafez opened this issue Jul 11, 2022 · 1 comment
Closed
2 tasks done

types: $addFields is broken with nested fields #12089

AbdelrahmanHafez opened this issue Jul 11, 2022 · 1 comment
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@AbdelrahmanHafez
Copy link
Collaborator

AbdelrahmanHafez commented Jul 11, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.4.4

Node.js version

16.6

MongoDB server version

5.x

Description

In MongoDB the following are valid expressions, but throw in our TS types.

const nestedAddFieldsExpr: PipelineStage.AddFields = {
  $addFields: {
    parent: {
      nestedField: { $add: ['$a', '$b'] }
    }
  }
};
const addFieldsArrayElemAt: PipelineStage.AddFields = {
  $addFields: {
    parent: {
      child: { $arrayElemAt: ['$someArray', 0] }
    }
  }
};

The current types only support flat-level fields, and the only way we can achieve that is by changing it in the code to:

'parentPath.nestedPath': { $add: [1, 2] }

Expected Behavior

It should support nested paths.

@AbdelrahmanHafez AbdelrahmanHafez added the typescript Types or Types-test related issue / Pull Request label Jul 11, 2022
@vkarpov15 vkarpov15 modified the milestones: 6.4.6, 6.4.5 Jul 17, 2022
@vkarpov15
Copy link
Collaborator

Looks like this was fixed by same fix as #12096 , fix will be in 6.4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

2 participants