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($addToSet) is readonly #12091

Closed
2 tasks done
AbdelrahmanHafez opened this issue Jul 11, 2022 · 0 comments
Closed
2 tasks done

types($addToSet) is readonly #12091

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

Comments

@AbdelrahmanHafez
Copy link
Collaborator

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.x

MongoDB server version

5.x

Description

Currently, $addToSet is readonly which disallows people from constructing the $addToSet programatically.

Steps to Reproduce

function addToSetMutable() {
  interface IUser{
    friendsNames: string[];
  }
  const userSchema = new Schema<IUser>({
    friendsNames: [String]
  });

  const update: UpdateQuery<IUser> = { $addToSet: { friendsNames: 'John Doe' } };
  update.$addToSet.friendsNames = 'Jane Doe';
}

Expected Behavior

It should be mutable, to be able to programatically construct the $addToSet object.
One challenge is that we're using $addToSet from mongodb types, so changing that can be a bit tricky.

@AbdelrahmanHafez AbdelrahmanHafez added the typescript Types or Types-test related issue / Pull Request label Jul 11, 2022
@vkarpov15 vkarpov15 added this to the 6.4.5 milestone Jul 17, 2022
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