Skip to content

Conversation

mernxl
Copy link
Owner

@mernxl mernxl commented Dec 5, 2019

Code base optimized and tested against

  • MongoDB v3.4, v3.6, v4.0, v4.2
  • Node version v8, v10 and v12

This is same as #3

mernxl added 30 commits July 27, 2018 06:50
…t manually initialised

Fixes the reliance on initialising the assigner
…er instance.

Use `MongooseIdAssigner Constructor` to get Instance. The interface `AssignerOptions` also changed,
modelName not needed. Use `AssignerPluginOptions` when using with `schema.plugin(..., options)`.
* perf(pre-save): remove checks for `options.fields` as it never gets called

* test: write some more test cases
* fix: flow parse of .json file in `config-chain` package

* chore: add babel-jest, peer dependency to ts-jest
This helps reduce the weight of code, especially when you don't intend on using uuids as ids
…Instance`

BREAKING CHANGE: `MongooseIdAssigner.plugin` will NOT return IdAssigner instance. It is intended to be used only with like so -> `schema.plugin(MongooseIdAssigner.plugin, options)`.
Use `MongooseIdAssigner Constructor` to get Instance. It takes parameters `ModelInstance` and `AssignerOptions`. The interface `AssignerOptions` also changed, modelName not needed. Use `AssignerPluginOptions` when working with `schema.plugin(..., options)`.
@see Automattic/mongoose#5073

`pre-save` hooks not triggered if set after initialising model for mongoose >= 4.8.0, so all models whose Assigner was initialised using MongooseIdAssigner constructor will fail, but those with MongooseIdAssigner.plugin is ok.
BREAKING CHANGE:
@see Automattic/mongoose#5073
MongooseIdAssigner WILL NOT BE initialised using Models.
Plugin can now only be used by calling `schema.plugin(MongooseIdAssigner, options)`
or `schema.plugin(MongooseIdAssigner.plugin, options)`

To get IdAssigner Instance,
1: Get from `localStateStore.getIdAssigner(schema)`
2: Use `const IA = MongooseIdAssigner.plugin(schema, options)`
3: Use `const IA = new MongooseIdAssigner(schema, options)`
mernxl added 23 commits December 5, 2019 03:31
@mernxl mernxl merged commit 215de33 into master Dec 5, 2019
@mernxl
Copy link
Owner Author

mernxl commented Dec 5, 2019

🎉 This PR is included in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mernxl mernxl added the released label Dec 5, 2019
mernxl added a commit that referenced this pull request Dec 5, 2019
…4, v3.6, v4.0, v4.2

Code base optimized and tested against

MongoDB v3.4, v3.6, v4.0, v4.2
Node version v8, v10 and v12

There was an issue why publishing from previous pull #2 . Redo to ensure correct semver numbers set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant