mongoose 5.12.4 → 5.12.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/History.md +62 -0
  2. package/LICENSE.md +2 -1
  3. package/dist/browser.umd.js +110 -110
  4. package/index.d.ts +147 -119
  5. package/lib/connection.js +12 -3
  6. package/lib/cursor/QueryCursor.js +13 -3
  7. package/lib/document.js +15 -4
  8. package/lib/drivers/browser/index.js +3 -0
  9. package/lib/drivers/node-mongodb-native/collection.js +0 -1
  10. package/lib/drivers/node-mongodb-native/connection.js +25 -18
  11. package/lib/drivers/node-mongodb-native/index.js +2 -1
  12. package/lib/error/cast.js +3 -2
  13. package/lib/helpers/cursor/eachAsync.js +20 -8
  14. package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +16 -0
  15. package/lib/helpers/discriminator/getConstructor.js +1 -1
  16. package/lib/helpers/discriminator/getDiscriminatorByValue.js +10 -10
  17. package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +3 -1
  18. package/lib/helpers/model/castBulkWrite.js +1 -1
  19. package/lib/helpers/model/discriminator.js +4 -1
  20. package/lib/helpers/path/parentPaths.js +13 -0
  21. package/lib/helpers/populate/assignVals.js +4 -4
  22. package/lib/helpers/populate/createPopulateQueryFilter.js +79 -0
  23. package/lib/helpers/populate/getModelsMapForPopulate.js +17 -20
  24. package/lib/helpers/populate/getSchemaTypes.js +1 -1
  25. package/lib/helpers/populate/lookupLocalFields.js +3 -0
  26. package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +1 -1
  27. package/lib/helpers/schema/applyWriteConcern.js +21 -7
  28. package/lib/helpers/schema/merge.js +9 -1
  29. package/lib/index.js +9 -12
  30. package/lib/model.js +59 -97
  31. package/lib/query.js +80 -18
  32. package/lib/queryhelpers.js +1 -1
  33. package/lib/schema/array.js +6 -6
  34. package/lib/schema.js +4 -7
  35. package/lib/types/documentarray.js +2 -2
  36. package/lib/utils.js +6 -6
  37. package/package.json +22 -19
package/History.md CHANGED
@@ -1,3 +1,65 @@
1
+ 5.12.8 / 2021-05-10
2
+ ===================
3
+ * fix(populate): handle populating immutable array paths #10159
4
+ * fix(CastError): add `toJSON()` function to ensure `name` property always ends up in `JSON.stringify()` output #10166 [IslandRhythms](https://github.com/IslandRhythms)
5
+ * fix(query): add allowDiskUse() method to improve setting MongoDB 4.4's new `allowDiskUse` option #10177
6
+ * fix(populate): allow populating paths under mixed schematypes where some documents have non-object properties #10191
7
+ * chore: remove unnecessary driver dynamic imports so Mongoose can work with Parcel #9603
8
+ * fix(index.d.ts): allow any object as parameter to create() and `insertMany()` #10144
9
+ * fix(index.d.ts): allow creating Model class with raw interface, no `extends Document` #10144
10
+ * fix(index.d.ts): separate UpdateQuery from `UpdateWithAggregationPipeline` for cases when `UpdateQuery` is used as a function param #10186
11
+ * fix(index.d.ts): don't require error value in pre/post hooks #10213 [michaln-q](https://github.com/michaln-q)
12
+ * docs(typescript): add a typescript intro tutorial and statics tutorial #10021
13
+ * docs(typescript): add query helpers tutorial #10021
14
+ * docs(deprecations): add note that you can safely ignore `useFindAndModify` and `useCreateIndex` deprecation warnings #10155
15
+ * chore(workflows): add node 16 to github actions #10201 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
16
+
17
+ 5.12.7 / 2021-04-29
18
+ ===================
19
+ * fix(document): make $getPopulatedDocs() return populated virtuals #10148
20
+ * fix(discriminator): take discriminator schema's single nested paths over base schema's #10157
21
+ * fix(discriminator): allow numbers and ObjectIds as tied values for discriminators #10130
22
+ * fix(document): avoid double validating paths underneath mixed objects in save() #10141
23
+ * fix(schema): allow path() to return single nested paths within document arrays #10164
24
+ * fix(model+query): consistently wrap query callbacks in `process.nextTick()` to avoid clean stack traces causing memory leak when using synchronous recursion like `async.whilst()` #9864
25
+ * fix(cursor): correctly report CastError when using noCursorTimeout flag #10150
26
+ * fix(index.d.ts): add CastError constructor #10176
27
+ * fix(index.d.ts): allow setting mongoose.pluralize(null) in TypeScript #10185
28
+ * docs: add link to transactions guide from nav bar #10143
29
+ * docs(validation): add section about custom error messages #10140
30
+ * docs: make headers linkable via clicking #10156
31
+ * docs: broken link in document.js #10190 [joostdecock](https://github.com/joostdecock)
32
+ * docs: make navbar responsive on legacy 2.x docs #10171 [ad99526](https://github.com/ad99526)
33
+
34
+ 5.12.6 / 2021-04-27
35
+ ===================
36
+ * fix(query): allow setting `writeConcern` schema option to work around MongoDB driver's `writeConcern` deprecation warning #10083 #10009 [IslandRhythms](https://github.com/IslandRhythms)
37
+ * fix(populate): dedupe when virtual populate foreignField is an array to avoid duplicate docs in result #10117
38
+ * fix(populate): add `localField` filter to `$elemMatch` on virtual populate when custom `match` has a `$elemMatch` and `foreignField` is an array #10117
39
+ * fix(query): convert projection string values to numbers as a workaround for #10142
40
+ * fix(document): set version key filter on `save()` when using `optimisticConcurrency` if no changes in document #10128 [IslandRhythms](https://github.com/IslandRhythms)
41
+ * fix(model): use `obj` as `context` in `Model.validate()` if `obj` is a document #10132
42
+ * fix(connection): avoid db events deprecation warning when using `useDb()` with `useUnifiedTopology` #8267
43
+ * fix: upgrade to sift@13.5.2 to work around transitive dev dependency security warning #10121
44
+ * fix(index.d.ts): allow any object as parameter to `create()` and `insertMany()` #10144
45
+ * fix(index.d.ts): clarify that `eachAsync()` callback receives a single doc rather than array of docs unless `batchSize` is set #10135
46
+ * fix(index.d.ts): clarify that return value from `validateSync()` is a ValidationError #10147 [michaln-q](https://github.com/michaln-q)
47
+ * fix(index.d.ts): add generic type for Model constructor #10074 [Duchynko](https://github.com/Duchynko)
48
+ * fix(index.d.ts): add parameter type in merge #10168 [yoonhoGo](https://github.com/yoonhoGo)
49
+
50
+ 5.12.5 / 2021-04-19
51
+ ===================
52
+ * fix(populate): handle populating underneath document array when document array property doesn't exist in db #10003
53
+ * fix(populate): clear out dangling pointers to populated docs so query cursor with populate() can garbage collect populated subdocs #9864
54
+ * fix(connection): pull correct `autoCreate` value from Mongoose global when creating new model before calling `connect()` #10091
55
+ * fix(populate): handle populating paths on documents with discriminator keys that point to non-existent discriminators #10082
56
+ * fix(index.d.ts): allow numbers as discriminator names #10115
57
+ * fix(index.d.ts): allow `type: Boolean` in Schema definitions #10085
58
+ * fix(index.d.ts): allow passing array of aggregation pipeline stages to `updateOne()` and `updateMany()` #10095
59
+ * fix(index.d.ts): support legacy 2nd param callback syntax for `deleteOne()`, `deleteMany()` #10122
60
+ * docs(mongoose): make `useCreateIndex` always `false` in docs #10033
61
+ * docs(schema): fix incorrect links from schema API docs #10111
62
+
1
63
  5.12.4 / 2021-04-15
2
64
  ===================
3
65
  * fix: upgrade mongodb driver -> 3.6.6 #10079
package/LICENSE.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2010 LearnBoost <dev@learnboost.com>
3
+ Copyright (c) 2010-2013 LearnBoost <dev@learnboost.com>
4
+ Copyright (c) 2013-2021 Automattic
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal