Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Automattic/mongoose
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0496de9f66142906c9fd91a0be2fccbfb8c1de7f
Choose a base ref
...
head repository: Automattic/mongoose
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d2b846fc8f850a82605b74148854a79769f7019b
Choose a head ref

Commits on Jun 26, 2021

  1. Upgrade CI environment to Ubuntu 20.04

    Also refactor connection tests to remove use of mongodb-topology-manager
    YC committed Jun 26, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    1111f2f View commit details

Commits on Jun 27, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    abf3b43 View commit details

Commits on Jun 30, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    abdc617 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    74181e3 View commit details

Commits on Jul 1, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    18c9b8b View commit details
  2. fix(index.d.ts): allow using & Document in schema definition for re…

    …quired subdocument arrays
    
    Fix #10370
    vkarpov15 committed Jul 1, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    6993e1e View commit details
  3. test(model): repro #10303

    vkarpov15 committed Jul 1, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b236915 View commit details
  4. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    35d2041 View commit details
  5. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    e4ab2db View commit details
  6. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8fbe0c7 View commit details

Commits on Jul 2, 2021

  1. revert test.yml

    YC committed Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    d859617 View commit details
  2. fix: support for mongod < 4.4.0

    YC committed Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    de5632e View commit details
  3. fix(index.d.ts): if using DocType that doesn't extends Document, de…

    …fault to returning that DocType from `toObject()` and `toJSON()`
    
    Fix #10345
    vkarpov15 committed Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    01c25ee View commit details
  4. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    5427f21 View commit details
  5. fix(index.d.ts): use raw DocType instead of LeanDocument when using…

    … `lean()` with queries if raw DocType doesn't `extends Document`
    
    Fix #10345
    vkarpov15 committed Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    c8a0b53 View commit details
  6. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    4d43d1b View commit details
  7. Merge pull request #10395 from thiagokisaki/patch-2

    fix(index.d.ts): proper placement of `mongoose.Date` JSDoc
    vkarpov15 authored Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    4831b9d View commit details
  8. Merge pull request #10406 from grimmer0125/fix-outdated-unindexed-ups…

    …ert-url
    
    [doc] Fix outdated URL about unindexed upsert
    vkarpov15 authored Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    0dfad27 View commit details
  9. Merge pull request #10393 from YC/20.04

    Replace mongodb-topology-manager
    vkarpov15 authored Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    5aeae5a View commit details
  10. chore: release 5.13.1

    vkarpov15 committed Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    5bbc8e0 View commit details
  11. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    6661b00 View commit details
  12. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    980138d View commit details
  13. docs: add SchemaArray to docs

    Fix #10397
    vkarpov15 committed Jul 2, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    2259dc1 View commit details

Commits on Jul 3, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    ccfb86e View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    d250ddc View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    726ce8b View commit details
  4. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    1159631 View commit details
  5. style: fix lint

    vkarpov15 committed Jul 3, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    4482592 View commit details
  6. chore: release 5.13.2

    vkarpov15 committed Jul 3, 2021
    Copy the full SHA
    c03cacb View commit details

Commits on Jul 8, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    benjamn Ben Newman
    Copy the full SHA
    e1fcf29 View commit details
  2. Copy the full SHA
    ca34cfa View commit details

Commits on Jul 9, 2021

  1. Copy the full SHA
    ac545ef View commit details
  2. Merge pull request #10440 from AbdelrahmanHafez/patch-10

    bump native driver to 3.6.10
    vkarpov15 authored Jul 9, 2021
    Copy the full SHA
    c01685a View commit details

Commits on Jul 12, 2021

  1. Copy the full SHA
    6250841 View commit details

Commits on Jul 13, 2021

  1. Copy the full SHA
    a22c908 View commit details

Commits on Jul 15, 2021

  1. fix(types): remove discriminator type requirement

    Since Model enforces Document when needed,
    the discriminator type parameter don't need to extend it
    DouglasGabr committed Jul 15, 2021
    Copy the full SHA
    982a389 View commit details

Commits on Jul 16, 2021

  1. fix(index.d.ts): consistently use NativeDate instead of Date for Date…

    … validators and timestamps functions
    
    Fix #10246
    vkarpov15 committed Jul 16, 2021
    Copy the full SHA
    5edb25d View commit details
  2. Merge pull request #10452 from DouglasGabr/master

    fix(types): remove discriminator type requirement
    vkarpov15 authored Jul 16, 2021
    Copy the full SHA
    ed1bffb View commit details
  3. Copy the full SHA
    34d2796 View commit details
  4. Copy the full SHA
    ad8ca76 View commit details
  5. test(model): repro #9673

    vkarpov15 committed Jul 16, 2021
    Copy the full SHA
    c1ce3c9 View commit details
  6. 2
    Copy the full SHA
    16b6a37 View commit details
  7. test(schema): repro #10436

    vkarpov15 committed Jul 16, 2021
    Copy the full SHA
    acd262c View commit details
  8. fix(schema): allow calling Schema#loadClass() with class that has a…

    … static getter with no setter
    
    Fix #10436
    vkarpov15 committed Jul 16, 2021
    Copy the full SHA
    169f9e1 View commit details
  9. test(timestamps): repro #10447

    vkarpov15 committed Jul 16, 2021
    Copy the full SHA
    c6a646c View commit details
  10. fix(timestamps): apply timestamps when creating new subdocs with `$ad…

    …dToSet` and with positional operator
    
    Fix #10447
    vkarpov15 committed Jul 16, 2021
    Copy the full SHA
    66fd25f View commit details
  11. Merge pull request #10442 from semirturgay/gh-broken-defaults

    fix(model): applying object defaults
    vkarpov15 authored Jul 16, 2021
    Copy the full SHA
    88a32fe View commit details
  12. chore: release 5.13.3

    vkarpov15 committed Jul 16, 2021
    Copy the full SHA
    3924628 View commit details

Commits on Jul 17, 2021

  1. Copy the full SHA
    e4be278 View commit details
  2. Copy the full SHA
    8122374 View commit details
Showing with 1,702 additions and 542 deletions.
  1. +123 −0 History.md
  2. +6 −0 Makefile
  3. +1 −1 docs/discriminators.md
  4. +41 −39 docs/layout.pug
  5. +1 −1 docs/models.md
  6. +1 −1 docs/promises.md
  7. +7 −2 docs/source/api.js
  8. +5 −0 docs/transactions.md
  9. +1 −1 docs/tutorials/findoneandupdate.md
  10. +442 −273 index.d.ts
  11. +24 −6 index.pug
  12. +2 −1 lib/aggregate.js
  13. +2 −1 lib/cast.js
  14. +2 −1 lib/connection.js
  15. +13 −8 lib/cursor/AggregationCursor.js
  16. +23 −10 lib/cursor/QueryCursor.js
  17. +28 −3 lib/document.js
  18. +12 −9 lib/drivers/node-mongodb-native/collection.js
  19. +2 −1 lib/error/validation.js
  20. +7 −7 lib/helpers/document/compile.js
  21. +15 −0 lib/helpers/getConstructorName.js
  22. +5 −8 lib/helpers/model/discriminator.js
  23. +6 −1 lib/helpers/populate/assignRawDocsToIdStructure.js
  24. +3 −0 lib/helpers/populate/assignVals.js
  25. +2 −2 lib/helpers/populate/getModelsMapForPopulate.js
  26. +3 −0 lib/helpers/populate/lookupLocalFields.js
  27. +2 −1 lib/helpers/query/castUpdate.js
  28. +1 −1 lib/helpers/timestamps/setupTimestamps.js
  29. +3 −2 lib/helpers/topology/allServersUnknown.js
  30. +3 −2 lib/helpers/topology/isAtlas.js
  31. +3 −2 lib/helpers/topology/isSSLError.js
  32. +41 −28 lib/helpers/update/applyTimestampsToChildren.js
  33. +1 −1 lib/index.js
  34. +24 −15 lib/model.js
  35. +19 −3 lib/query.js
  36. +38 −14 lib/schema.js
  37. +5 −3 lib/schema/array.js
  38. +2 −1 lib/schema/date.js
  39. +2 −1 lib/schema/objectid.js
  40. +1 −1 lib/types/embedded.js
  41. +4 −2 lib/types/map.js
  42. +3 −1 lib/utils.js
  43. +10 −7 package.json
  44. +0 −17 test/common.js
  45. +16 −1 test/connection.test.js
  46. +80 −0 test/connection_server.js
  47. +3 −3 test/docs/validation.test.js
  48. +68 −9 test/document.test.js
  49. +20 −0 test/model.discriminator.test.js
  50. +26 −0 test/model.findOneAndUpdate.test.js
  51. +88 −0 test/model.populate.test.js
  52. +75 −3 test/model.test.js
  53. +0 −20 test/model.update.test.js
  54. +124 −0 test/query.cursor.test.js
  55. +21 −0 test/schema.test.js
  56. +44 −0 test/timestamps.test.js
  57. +28 −2 test/typescript/document.ts
  58. +33 −1 test/typescript/leanDocuments.ts
  59. +15 −3 test/typescript/main.test.js
  60. +0 −1 test/typescript/middleware.ts
  61. +19 −0 test/typescript/models.ts
  62. +18 −3 test/typescript/populate.ts
  63. +23 −3 test/typescript/queries.ts
  64. +25 −1 test/typescript/schema.ts
  65. +28 −1 test/typescript/subdocuments.ts
  66. +9 −13 test/typescript/virtuals.ts
123 changes: 123 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,126 @@
5.13.14 / 2021-12-27
====================
* fix(timestamps): avoid setting createdAt on documents that already exist but dont have createdAt #11024
* docs(models): fix up nModified example for 5.x #11055

5.13.13 / 2021-11-02
====================
* fix: upgrade to mongodb@3.7.3 #10909 [gaurav-sharma-gs](https://github.com/gaurav-sharma-gs)
* fix: correctly emit end event in before close #10916 [iovanom](https://github.com/iovanom)
* fix(index.d.ts): improve ts types for query set #10942 [jneal-afs](https://github.com/jneal-afs)

5.13.12 / 2021-10-19
====================
* fix(cursor): use stream destroy method on close to prevent emitting duplicate 'close' #10897 [iovanom](https://github.com/iovanom)
* fix(index.d.ts): backport streamlining of FilterQuery and DocumentDefinition to avoid "excessively deep and possibly infinite" TS errors #10617

5.13.11 / 2021-10-12
====================
* fix: upgrade mongodb -> 3.7.2 #10871 [winstonralph](https://github.com/winstonralph)
* fix(connection): call setMaxListeners(0) on MongoClient to avoid event emitter memory leak warnings with `useDb()` #10732

5.13.10 / 2021-10-05
====================
* fix(index.d.ts): allow using type: SchemaDefinitionProperty in schema definitions #10674
* fix(index.d.ts): allow AnyObject as param to findOneAndReplace() #10714

5.13.9 / 2021-09-06
===================
* fix(populate): avoid setting empty array on lean document when populate result is undefined #10599
* fix(document): make depopulate() handle populated paths underneath document arrays #10592
* fix: peg @types/bson version to 1.x || 4.0.x to avoid stubbed 4.2.x release #10678
* fix(index.d.ts): simplify UpdateQuery to avoid "excessively deep and possibly infinite" errors with `extends Document` and `any` #10647
* fix(index.d.ts): allow specifying weights as an IndexOption #10586
* fix: upgrade to mpath v0.8.4 re: security issue #10683

5.13.8 / 2021-08-23
===================
* fix(populate): handle populating subdoc array virtual with sort #10552
* fix(model): check for code instead of codeName when checking for existing collections for backwards compat with MongoDB 3.2 #10420
* fix(index.d.ts): correct value of this for custom query helper methods #10545
* fix(index.d.ts): allow strings for ObjectIds in nested properties #10573
* fix(index.d.ts): add match to VirtualTypeOptions.options #8749
* fix(index.d.ts): allow QueryOptions populate parameter type PopulateOptions #10587 [osmanakol](https://github.com/osmanakol)
* docs(api): add Document#$where to API docs #10583

5.13.7 / 2021-08-11
===================
* perf(index.d.ts): loosen up restrictions on ModelType generic for Schema for a ~50% perf improvement when compiling TypeScript and using intellisense #10536 #10515 #10349
* fix(index.d.ts): fix broken `Schema#index()` types #10562 [JaredReisinger](https://github.com/JaredReisinger)
* fix(index.d.ts): allow using SchemaTypeOptions with array of raw document interfaces #10537
* fix(index.d.ts): define IndexOptions in terms of mongodb.IndexOptions #10563 [JaredReisinger](https://github.com/JaredReisinger)
* fix(index.d.ts): improve intellisense for DocumentArray `push()` #10546
* fix(index.d.ts): correct type for expires #10529
* fix(index.d.ts): add Query#model property to ts bindings #10531
* refactor(index.d.ts): make callbacks use the new Callback and CallbackWithoutResult types #10550 [thiagokisaki](https://github.com/thiagokisaki)

5.13.6 / 2021-08-09
===================
* fix: upgrade mongodb driver -> 3.6.11 #10543 [maon-fp](https://github.com/maon-fp)
* fix(schema): throw more helpful error when defining a document array using a schema from a different copy of the Mongoose module #10453
* fix: add explicit check on constructor property to avoid throwing an error when checking objects with null prototypes #10512
* fix(cursor): make sure to clear stack every 1000 docs when calling `next()` to avoid stack overflow with large batch size #10449
* fix(index.d.ts): improve types of Schema#(g|s)et #10555 [thiagokisaki](https://github.com/thiagokisaki)
* fix(index.d.ts): allow calling new Model(...) with generic Model param #10526
* fix(index.d.ts): update type declarations of Schema.index method #10538 #10530 [Raader](https://github.com/Raader)
* fix(index.d.ts): add useNewUrlParser and useUnifiedTopology to ConnectOptions #10500
* fix(index.d.ts): add missing type for diffIndexes #10547 [bvgusak](https://github.com/bvgusak)
* fix(index.d.ts): fixed incorrect type definition for Query's .map function #10544 [GCastilho](https://github.com/GCastilho)
* docs(schema): add more info and examples to Schema#indexes() docs #10446
* chore: add types property to package.json #10557 [thiagokisaki](https://github.com/thiagokisaki)

5.13.5 / 2021-07-30
===================
* perf(index.d.ts): improve typescript type checking performance #10515 [andreialecu](https://github.com/andreialecu)
* fix(index.d.ts): fix debug type in MongooseOptions #10510 [thiagokisaki](https://github.com/thiagokisaki)
* docs(api): clarify that `depopulate()` with no args depopulates all #10501 [gfrancz](https://github.com/gfrancz)

5.13.4 / 2021-07-28
===================
* fix: avoid pulling non-schema paths from documents into nested paths #10449
* fix(update): support overwriting nested map paths #10485
* fix(update): apply timestamps to subdocs that would be newly created by `$setOnInsert` #10460
* fix(map): correctly clone subdocs when calling toObject() on a map #10486
* fix(cursor): cap parallel batchSize for populate at 5000 #10449
* fix(index.d.ts): improve autocomplete for new Model() by making `doc` an object with correct keys #10475
* fix(index.d.ts): add MongooseOptions interface #10471 [thiagokisaki](https://github.com/thiagokisaki)
* fix(index.d.ts): make LeanDocument work with PopulatedDoc #10494
* docs(mongoose+connection): correct default value for bufferTimeoutMS #10476
* chore: remove unnecessary 'eslint-disable' comments #10466 [thiagokisaki](https://github.com/thiagokisaki)

5.13.3 / 2021-07-16
===================
* fix(model): avoid throwing error when bulkSave() called on a document with no changes #10437
* fix(timestamps): apply timestamps when creating new subdocs with `$addToSet` and with positional operator #10447
* fix(schema): allow calling Schema#loadClass() with class that has a static getter with no setter #10436
* fix(model): handle re-applying object defaults after explicitly unsetting #10442 [semirturgay](https://github.com/semirturgay)
* fix: bump mongodb driver -> 3.6.10 #10440 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
* fix(index.d.ts): consistently use NativeDate instead of Date for Date validators and timestamps functions #10426
* fix(index.d.ts): allow calling `discriminator()` with non-document #10452 #10421 [DouglasGabr](https://github.com/DouglasGabr)
* fix(index.d.ts): allow passing ResultType generic to Schema#path() #10435

5.13.2 / 2021-07-03
===================
* fix: hardcode @types/node version for now to avoid breaking changes from DefinitelyTyped/DefinitelyTyped#53669 #10415
* fix(index.d.ts): allow using type: Date with Date paths in SchemaDefinitionType #10409
* fix(index.d.ts): allow extra VirtualTypeOptions for better plugin support #10412
* docs(api): add SchemaArray to docs #10397
* docs(schema+validation): fix broken links #10396
* docs(transactions): add note about creating a connection to transactions docs #10406

5.13.1 / 2021-07-02
===================
* fix(discriminator): allow using array as discriminator key in schema and as tied value #10303
* fix(index.d.ts): allow using & Document in schema definition for required subdocument arrays #10370
* fix(index.d.ts): if using DocType that doesn't extends Document, default to returning that DocType from `toObject()` and `toJSON()` #10345
* fix(index.d.ts): use raw DocType instead of LeanDocument when using `lean()` with queries if raw DocType doesn't `extends Document` #10345
* fix(index.d.ts): remove err: any in callbacks, use `err: CallbackError` instead #10340
* fix(index.d.ts): allow defining map of schemas in TypeScript #10389
* fix(index.d.ts): correct return type for Model.createCollection() #10359
* docs(promises+discriminators): correctly escape () in regexp to pull in examples correctly #10364
* docs(update): fix outdated URL about unindexed upsert #10406 [grimmer0125](https://github.com/grimmer0125)
* docs(index.d.ts): proper placement of mongoose.Date JSDoc [thiagokisaki](https://github.com/thiagokisaki)

5.13.0 / 2021-06-28
===================
* feat(query): add sanitizeProjection option to opt in to automatically sanitizing untrusted query projections #10243
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -41,10 +41,16 @@ copytmp:
mkdir -p ./tmp/docs/css
mkdir -p ./tmp/docs/js
mkdir -p ./tmp/docs/images
mkdir -p ./tmp/docs/api
mkdir -p ./tmp/docs/tutorials
mkdir -p ./tmp/docs/typescript
cp -R ./docs/*.html ./tmp/docs
cp -R ./docs/css/*.css ./tmp/docs/css
cp -R ./docs/js/*.js ./tmp/docs/js
cp -R ./docs/images/* ./tmp/docs/images
cp -R ./docs/api/* ./tmp/docs/api
cp -R ./docs/tutorials/* ./tmp/docs/tutorials
cp -R ./docs/typescript/* ./tmp/docs/typescript
cp index.html ./tmp

gitreset:
2 changes: 1 addition & 1 deletion docs/discriminators.md
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ key (defaults to the model name). It returns a model whose schema
is the union of the base schema and the discriminator schema.

```javascript
[require:The `model.discriminator()` function]
[require:The `model.discriminator\(\)` function]
```

### Discriminators save to the Event model's collection
Loading