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

Add usePushEach flag to Mongoose Schema Options #23042

Merged
merged 1 commit into from Jan 19, 2018
Merged

Add usePushEach flag to Mongoose Schema Options #23042

merged 1 commit into from Jan 19, 2018

Conversation

stieg
Copy link
Contributor

@stieg stieg commented Jan 19, 2018

In order for devs to be able to work around the issues described in
Automattic/mongoose#5574 we need to be able
to supply the usePushEach flag to the Mongoose SchemaOptions. This
options functionality is described in
Automattic/mongoose#4455 and is required for
anyone who modifies arrays inline who is using Mongoose 4 and MongoDB
3.6+

Testing:
Copied changes to local project and verified compilation worked.

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If adding a new definition:

  • The package does not provide its own types, and you can not add them.
  • If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • tslint.json should be present, and tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: <>
  • Increase the version number in the header if appropriate.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }.

If removing a declaration:

  • If a package was never on DefinitelyTyped, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
  • Delete the package's directory.
  • Add it to notNeededPackages.json.

In order for devs to be able to work around the issues described in
Automattic/mongoose#5574 we need to be able
to supply the `usePushEach` flag to the Mongoose SchemaOptions. This
options functionality is described in
Automattic/mongoose#4455 and is required for
anyone who modifies arrays inline who is using Mongoose 4 and MongoDB
3.6+

Testing:
  Copied changes to local project and verified compilation worked.
@typescript-bot
Copy link
Contributor

typescript-bot commented Jan 19, 2018

@stieg Thank you for submitting this PR!

🔔 @simonxca @horiuchi @sindrenm @lukasz-zak - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@simonbear89
Copy link
Contributor

simonbear89 commented Jan 19, 2018

@stieg Thanks! LGTM.

@typescript-bot
Copy link
Contributor

A definition author has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped!

@weswigham weswigham merged commit d512b1f into DefinitelyTyped:master Jan 19, 2018
@typescript-bot typescript-bot removed this from Merge: Express in Pull Request Triage Backlog Jan 19, 2018
@EtienneBoutet
Copy link

Did the option been added ? It's not there in 5.0.16..

@stieg
Copy link
Contributor Author

stieg commented Jun 18, 2018

Hrmm... Option was added in commit d512b1f but seems to have been removed in commit ccdc539 by Art a.molcanovas@gmail.com. Maintainers... know whats up with this? This because of mongoose 5 and this feature may be unnecessary now (my best guess)?

@EtienneBoutet
Copy link

The problem still exists with Mongoose (¢pushAll).. I did another PR for this and they added it.. Do you know any work around if they decide to remove it once again ?

@stieg
Copy link
Contributor Author

stieg commented Jun 19, 2018

@EtienneBoutet I simply did a type assertion to work around the issue when defining my Schema Options. Something like this was my workaround

const MySchema = new Schema({
   ...
}, {
   timestamps: true,
   usePushEach: true,
} as SchemaOptions);

@EtienneBoutet
Copy link

Thanks a lot ! 👍

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.

None yet

6 participants