Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
* fix(discriminator): allow user-defined discriminator path in schema #7807
* fix(query): ensure `findOneAndReplace()` sends `replacement` to server #7654
* fix(cast): allow `[]` as a value when casting `$nin` #7806
* docs(model): clarify that setters do run on `update()` by default #7801
* docs: fix typo in FAQ #7821 [jaona](https://github.com/jaona)
5.5.9 / 2019-05-16
==================
* fix(query): skip schema setters when casting $regexp $options #7802 [Fonger](https://github.com/Fonger)
* fix(populate): don't skip populating doc array properties whose name conflicts with an array method #7782
* fix(populate): make populated virtual return undefined if not populated #7795
* fix(schema): handle custom setters in arrays of document arrays #7804 [Fonger](https://github.com/Fonger)
* docs(tutorials): add query casting tutorial #7789
5.5.8 / 2019-05-13
==================
* fix(document): run pre save hooks on nested child schemas #7792
* fix(model): set $session() before validation middleware for bulkWrite/insertMany #7785 #7769 [Fonger](https://github.com/Fonger)
* fix(query): make `getPopulatedPaths()` return deeply populated paths #7757
* fix(query): suppress findAndModify deprecation warning when using `Model.findOneAndUpdate()` #7794
* fix: upgrade mongodb -> 3.2.4 #7794
* fix(document): handle a couple edge cases with atomics that happen when schema defines an array property named 'undefined' #7756
* docs(discriminator): correct function parameters #7786 [gfpacheco](https://github.com/gfpacheco)
5.5.7 / 2019-05-09
==================
* fix(model): set $session() before pre save middleware runs when calling save() with options #7742
* fix(model): set $session before pre remove hooks run when calling remove() with options #7742
* fix(schema): support `remove()` on nested path #2398
* fix(map): handle setting populated map element to doc #7745
* fix(query): return rawResult when inserting with options `{new:false,upsert:true,rawResult:true}` #7774 #7770 [LiaanM](https://github.com/LiaanM)
* fix(schematype): remove internal `validators` option because it conflicts with Backbone #7720
5.5.6 / 2019-05-06
==================
* fix(document): stop converting arrays to objects when setting non-schema path to array with strict: false #7733
* fix(array): make two Mongoose arrays `assert.deepEqual()` each other if they have the same values #7700
* fix(populate): support populating a path in a document array embedded in an array #7647
* fix(populate): set populate virtual count to 0 if local field is empty #7731
* fix(update): avoid throwing cast error if casting array filter that isn't in schema with strictQuery = false #7728
* docs: fix typo in `distinct()` description #7767 [phil-r](https://github.com/phil-r)
5.5.5 / 2019-04-30
==================
* fix(document): ensure nested properties within single nested subdocs get set correctly when overwriting single nested subdoc #7748
* fix(document): skip non-object `validators` in schema types #7720
* fix: bump mongodb driver -> 3.2.3 #7752
* fix(map): disallow setting map key with special properties #7750 [Fonger](https://github.com/Fonger)
5.5.4 / 2019-04-25
==================
* fix(document): avoid calling custom getters when saving #7719
* fix(timestamps): handle child schema timestamps correctly when reusing child schemas #7712
* fix(query): pass correct callback for _legacyFindAndModify #7736 [Fonger](https://github.com/Fonger)
* fix(model+query): allow setting `replacement` parameter for `findOneAndReplace()` #7654
* fix(map): make `delete()` unset the key in the database #7746 [Fonger](https://github.com/Fonger)
* fix(array): use symbol for `_schema` property to avoid confusing deep equality checks #7700
* fix(document): prevent `depopulate()` from removing fields with empty array #7741 #7740 [Fonger](https://github.com/Fonger)
* fix: make `MongooseArray#includes` support ObjectIds #7732 #6354 [hansemannn](https://github.com/hansemannn)
* fix(document): report correct validation error index when pushing onto doc array #7744 [Fonger](https://github.com/Fonger)
5.5.3 / 2019-04-22
==================
* fix: add findAndModify deprecation warning that references the useFindAndModify option #7644
* fix(document): handle pushing a doc onto a discriminator that contains a doc array #7704
* fix(update): run setters on array elements when doing $set #7679
* fix: correct usage of arguments while buffering commands #7718 [rzymek](https://github.com/rzymek)
* fix(document): avoid error clearing modified subpaths if doc not defined #7715 [bitflower](https://github.com/bitflower)
* refactor(array): move `_parent` property behind a symbol #7726 #7700
* docs(model): list out all operations and options for `bulkWrite()` #7055
* docs(aggregate): use `eachAsync()` instead of nonexistent `each()` #7699
* docs(validation): add CastError validation example #7514
* docs(query+model): list out all options and callback details for Model.updateX() and Query#updateX() #7646
5.5.2 / 2019-04-16
==================
* fix(document): support setting nested path to non-POJO object #7639
* perf(connection): remove leaked event handler in `Model.init()` so `deleteModel()` frees all memory #7682
* fix(timestamps): handle custom statics that conflict with built-in functions (like mongoose-delete plugin) #7698
* fix(populate): make `Document#populated()` work for populated subdocs #7685
* fix(document): support `.set()` on document array underneath embedded discriminator path #7656
5.5.1 / 2019-04-11
==================
* fix(document): correctly overwrite all properties when setting a single nested subdoc #7660 #7681
* fix(array): allow customization of array required validator #7696 [freewil](https://github.com/freewil)
* fix(discriminator): handle embedded discriminators when casting array defaults #7687
* fix(collection): ensure collection functions return a promise even if disconnected #7676
* fix(schematype): avoid indexing properties with `{ unique: false, index: false }` #7620
* fix(aggregate): make `Aggregate#model()` with no arguments return the aggregation's model #7608
5.5.0 / 2019-04-08
==================
* feat(model): support applying hooks to custom static functions #5982
* feat(populate): support specifying a function as `match` #7397
* perf(buffer): avoid calling `defineProperties()` in Buffer constructor #7331
* feat(connection): add `plugin()` for connection-scoped plugins #7378
* feat(model): add Model#deleteOne() and corresponding hooks #7538
* feat(query): support hooks for `Query#distinct()` #5938
* feat(model): print warning when calling create() incorrectly with a session #7535
* feat(document): add Document#isEmpty() and corresponding helpers for nested paths #5369
* feat(document): add `getters` option to Document#get() #7233
* feat(query): add Query#projection() to get or overwrite the current projection #7384
* fix(document): set full validator path on validatorProperties if `propsParameter` set on validator #7447
* feat(document): add Document#directModifiedPaths() #7373
* feat(document): add $locals property #7691
* feat(document): add validateUpdatedOnly option that only validates modified paths in `save()` #7492 [captaincaius](https://github.com/captaincaius)
* chore: upgrade MongoDB driver to v3.2.0 #7641
* fix(schematype): deprecate `isAsync` option for custom validators #6700
* chore(mongoose): deprecate global.MONGOOSE_DRIVER_PATH so we can be webpack-warning-free in 6.0 #7501
5.4.23 / 2019-04-08
===================
* fix(document): report cast error when string path in schema is an array in MongoDB #7619
* fix(query): set deletedCount on result of remove() #7629
* docs(subdocs): add note about parent() and ownerDocument() to subdocument docs #7576
5.4.22 / 2019-04-04
===================
* fix(aggregate): allow modifying options in pre('aggregate') hook #7606
* fix(map): correctly init maps of maps when loading from MongoDB #7630
* docs(model+query): add `omitUndefined` option to docs for updateX() and findOneAndX() #3486
* docs: removed duplicate Query.prototype.merge() reference from doc #7684 [shihabmridha](https://github.com/shihabmridha)
* docs(schema): fix shardKey type to object instead of bool #7668 [kyletsang](https://github.com/kyletsang)
* docs(api): fix `Model.prototypedelete` link #7665 [pixcai](https://github.com/pixcai)
5.4.21 / 2019-04-02
===================
* fix(updateValidators): run update validators correctly on Decimal128 paths #7561
* fix(update): cast array filters in nested doc arrays correctly #7603
* fix(document): allow .get() + .set() with aliased paths #7592
* fix(document): ensure custom getters on single nested subdocs don't get persisted if toObject.getters = true #7601
* fix(document): support setting subdoc path to subdoc copied using object rest `{...doc}` #7645
* docs(schema): correct out-of-date list of reserved words #7593
* docs(model+query): add link to update results docs and examples of using results of updateOne(), etc. #7582
* docs: use atomic as opposed to $atomic consistently #7649 [720degreeLotus](https://github.com/720degreeLotus)
5.4.20 / 2019-03-25
===================
* docs(tutorials): add tutorial about `lean()` #7640
* fix(discriminator): fix wrong modelName being used as value to partialFilterExpression index #7635 #7634 [egorovli](https://github.com/egorovli)
* fix(document): allow setters to modify `this` when overwriting single nested subdoc #7585
* fix(populate): handle count option correctly with multiple docs #7573
* fix(date): support declaring min/max validators as functions #7600 [ChienDevIT](https://github.com/ChienDevIT)
* fix(discriminator): avoid projecting in embedded discriminator if only auto-selected path is discriminator key #7574
* fix(discriminator): use discriminator model when using `new BaseModel()` with discriminator key #7586
* fix(timestamps): avoid throwing if doc array has timestamps and array is undefined #7625 [serg33v](https://github.com/serg33v)
* docs(document): explain DocumentNotFoundError in save() docs #7580
* docs(query): fix .all() param type and add example #7612 [720degreeLotus](https://github.com/720degreeLotus)
* docs: add useNewUrlParser to mongoose.connect for some pages #7615 [YC](https://github.com/YC)
5.4.19 / 2019-03-11
===================
* fix(mongoose): ensure virtuals set on subdocs in global plugins get applied #7572
* docs(tutorials): add "Working With Dates" tutorial #7597
* docs(guide): clarify that versioning only affects array fields #7555
* docs(model): list out all bulkWrite() options #7550
5.4.18 / 2019-03-08
===================
* fix(document): handle nested virtuals in populated docs when parent path is projected out #7491
* fix(model): make subclassed models handle discriminators correctly #7547
* fix(model): remove $versionError from save options for better debug output #7570
5.4.17 / 2019-03-03
===================
* fix(update): handle all positional operator when casting array filters #7540
* fix(populate): handle populating nested path where top-level path is a primitive in the db #7545
* fix(update): run update validators on array filters #7536
* fix(document): clean modified subpaths when sorting an array #7556
* fix(model): cast $setOnInsert correctly with nested docs #7534
* docs: remove extra curly brace from example #7569 [kolya182](https://github.com/kolya182)
5.4.16 / 2019-02-26
===================
* fix(schema): handle nested objects with `_id: false` #7524
* fix(schema): don't throw error if declaring a virtual that starts with a map path name #7464
* fix(browser): add stubbed `model()` function so code that uses model doesn't throw #7541 [caub](https://github.com/caub)
* fix(schema): merge virtuals correctly #7563 [yoursdearboy](https://github.com/yoursdearboy)
* docs(connections): add reconnectFailed to connection docs #7477
* docs(index): fix typo #7553 [DenrizSusam](https://github.com/DenrizSusam)
* refactor(schema): iterate over paths instead of depending on childSchemas #7554
5.4.15 / 2019-02-22
===================
* fix(update): don't call schematype validators on array if using $pull with runValidators #6971
* fix(schema): clone all schema types when cloning an array #7537
* docs(connections): improve connectTimeoutMS docs and socketTimeoutMS docs to link to Node.js net.setTimeout() #5169
* docs: fix setters example in migration guide #7546 [freewil](https://github.com/freewil)
5.4.14 / 2019-02-19
===================
* fix(populate): make `getters` option handle nested paths #7521
* fix(documentarray): report validation errors that occur in an array subdoc created using `create()` and then `set()` #7504
* docs(schema): add examples for schema functions that didn't have any #7525
* docs: add MongooseError to API docs and add list of error names
* docs(CONTRIBUTING): fix link #7530 [sarpik](https://github.com/sarpik)
5.4.13 / 2019-02-15
===================
* fix(query): throw handy error when using updateOne() with overwrite: true and no dollar keys #7475
* fix(schema): support inheriting existing schema types using Node.js `util.inherits` like mongoose-float #7486
* docs(connections): add list of connection events #7477
5.4.12 / 2019-02-13
===================
* fix(connection): dont emit reconnected due to socketTimeoutMS #7452
* fix(schema): revert check for `false` schema paths #7516 #7512
* fix(model): don't delete unaliased keys in translateAliases #7510 [chrischen](https://github.com/chrischen)
* fix(document): run single nested schematype validator if nested path has a default and subpath is modified #7493
* fix(query): copy mongoose options when using `Query#merge()` #1790
* fix(timestamps): don't call createdAt getters when setting updatedAt on new doc #7496
* docs: improve description of ValidationError #7515 [JulioJu](https://github.com/JulioJu)
* docs: add an asterisk before comment, otherwise the comment line is not generated #7513 [JulioJu](https://github.com/JulioJu)
5.4.11 / 2019-02-09
===================
* fix(schema): handle `_id: false` in schema paths as a shortcut for setting the `_id` option to `false` #7480
* fix(update): handle $addToSet and $push with ObjectIds and castNonArrays=false #7479
* docs(model): document `session` option to `save()` #7484
* chore: fix gitignore syntax #7498 [JulioJu](https://github.com/JulioJu)
* docs: document that Document#validateSync returns ValidationError #7499
* refactor: use consolidated `isPOJO()` function instead of constructor checks #7500
5.4.10 / 2019-02-05
===================
* docs: add search bar and /search page #6706
* fix: support dotted aliases #7478 [chrischen](https://github.com/chrischen)
* fix(document): copy atomics when setting document array to an existing document array #7472
* chore: upgrade to mongodb driver 3.1.13 #7488
* docs: remove confusing references to executing a query "immediately" #7461
* docs(guides+schematypes): link to custom schematypes docs #7407
5.4.9 / 2019-02-01
==================
* fix(document): make `remove()`, `updateOne()`, and `update()` use the document's associated session #7455
* fix(document): support passing args to hooked custom methods #7456
* fix(document): avoid double calling single nested getters on `toObject()` #7442
* fix(discriminator): handle global plugins modifying top-level discriminator options with applyPluginsToDiscriminators: true #7458
* docs(documents): improve explanation of documents and use more modern syntax #7463
* docs(middleware+api): fix a couple typos in examples #7474 [arniu](https://github.com/arniu)
5.4.8 / 2019-01-30
==================
* fix(query): fix unhandled error when casting object in array filters #7431
* fix(query): cast query $elemMatch to discriminator schema if discriminator key set #7449
* docs: add table of contents to all guides #7430
5.4.7 / 2019-01-26
==================
* fix(populate): set `populated()` when using virtual populate #7440
* fix(discriminator): defer applying plugins to embedded discriminators until model compilation so global plugins work #7435
* fix(schema): report correct pathtype underneath map so setting dotted paths underneath maps works #7448
* fix: get debug from options using the get helper #7451 #7446 [LucGranato](https://github.com/LucGranato)
* fix: use correct variable name #7443 [esben-semmle](https://github.com/esben-semmle)
* docs: fix broken QueryCursor link #7438 [shihabmridha](https://github.com/shihabmridha)
5.4.6 / 2019-01-22
==================
* fix(utils): make minimize leave empty objects in arrays instead of setting the array element to undefined #7322
* fix(document): support passing `{document, query}` options to Schema#pre(regex) and Schema#post(regex) #7423
* docs: add migrating to 5 guide to docs #7434
* docs(deprecations): add instructions for fixing `count()` deprecation #7419
* docs(middleware): add description and example for aggregate hooks #7402
4.13.18 / 2019-01-21
====================
* fix(model): handle setting populated path set via `Document#populate()` #7302
* fix(cast): backport fix from #7290 to 4.x
5.4.5 / 2019-01-18
==================
* fix(populate): handle nested array `foreignField` with virtual populate #7374
* fix(query): support not passing any arguments to `orFail()` #7409
* docs(query): document what the resolved value for `deleteOne()`, `deleteMany()`, and `remove()` contains #7324
* fix(array): allow opting out of converting non-arrays into arrays with `castNonArrays` option #7371
* fix(query): ensure updateOne() doesnt unintentionally double call Schema#post(regexp) #7418
5.4.4 / 2019-01-14
==================
* fix(query): run casting on arrayFilters option #7079
* fix(document): support skipping timestamps on save() with `save({ timestamps: false })` #7357
* fix(model): apply custom where on `Document#remove()` so we attach the shardKey #7393
* docs(mongoose): document `mongoose.connections` #7338
5.4.3 / 2019-01-09
==================
* fix(populate): handle `count` option when using `Document#populate()` on a virtual #7380
* fix(connection): set connection state to DISCONNECTED if replica set has no primary #7330
* fix(mongoose): apply global plugins to schemas nested underneath embedded discriminators #7370
* fix(document): make modifiedPaths() return nested paths 1 level down on initial set #7313
* fix(plugins): ensure sharding plugin works even if ObjectId has a `valueOf()` #7353
5.4.2 / 2019-01-03
==================
* fix(document): ensure Document#updateOne() returns a query but still calls hooks #7366
* fix(query): allow explicitly projecting out populated paths that are automatically projected in #7383
* fix(document): support setting `flattenMaps` option for `toObject()` and `toJSON()` at schema level #7274
* fix(query): handle merging objectids with `.where()` #7360
* fix(schema): copy `.base` when cloning #7377
* docs: remove links to plugins.mongoosejs.com in favor of plugins.mongoosejs.io #7364
5.4.1 / 2018-12-26
==================
* fix(document): ensure doc array defaults get casted #7337
* fix(document): make `save()` not crash if nested doc has a property 'get' #7316
* fix(schema): allow using Schema.Types.Map as well as Map to declare a map type #7305
* fix(map): make set after init mark correct path as modified #7321
* fix(mongoose): don't recompile model if same collection and schema passed in to `mongoose.model()` #5767
* fix(schema): improve error message when type is invalid #7303
* fix(schema): add `populated` to reserved property names #7317
* fix(model): don't run built-in middleware on custom methods and ensure timestamp hooks don't run if children don't have timestamps set #7342
* docs(schematypes): clarify that you can add arbitrary options to a SchemaType #7340
* docs(mongoose): clarify that passing same name+schema to `mongoose.model()` returns the model #5767
* docs(index): add useNewUrlParser to example #7368 [JIBIN-P](https://github.com/JIBIN-P)
* docs(connection): add useNewUrlParser to examples #7362 [JIBIN-P](https://github.com/JIBIN-P)
* docs(discriminators): add back missing example from 'recursive embedded discriminators section' #7349
* docs(schema): improve docs for string and boolean cast() #7351
5.4.0 / 2018-12-14
==================
* feat(schematype): add `SchemaType.get()`, custom getters across all instances of a schematype #6912
* feat(schematype): add `SchemaType.cast()`, configure casting for individual schematypes #7045
* feat(schematype): add `SchemaType.checkRequired()`, configure what values pass `required` check for a schematype #7186 #7150
* feat(model): add `Model.findOneAndReplace()` #7162
* feat(model): add `Model.events` emitter that emits all `error`'s that occur with a given model #7125
* feat(populate): add `count` option to populate virtuals, support returning # of populated docs instead of docs themselves #4469
* feat(aggregate): add `.catch()` helper to make aggregations full thenables #7267
* feat(query): add hooks for `deleteOne()` and `deleteMany()` #7195
* feat(document): add hooks for `updateOne()` #7133
* feat(query): add `Query#map()` for synchronously transforming results before post middleware runs #7142
* feat(schema): support passing an array of objects or schemas to `Schema` constructor #7218
* feat(populate): add `clone` option to ensure multiple docs don't share the same populated doc #3258
* feat(query): add `Query#maxTimeMS()` helper #7254
* fix(query): deprecate broken `Aggregate#addCursorFlag()` #7120
* docs(populate): fix incorrect example #7335 [zcfan](https://github.com/zcfan)
* docs(middleware): add `findOneAndDelete` to middleware list #7327 [danielkesselberg](https://github.com/danielkesselberg)
5.3.16 / 2018-12-11
===================
* fix(document): handle `__proto__` in queries #7290
* fix(document): use Array.isArray() instead of checking constructor name for arrays #7290
* docs(populate): add section about what happens when no document matches #7279
* fix(mongoose): avoid crash on `import mongoose, {Schema} from 'mongoose'` #5648
5.3.15 / 2018-12-05
===================
* fix(query): handle `orFail()` with `findOneAndUpdate()` and `findOneAndDelete()` #7297 #7280
* fix(document): make `save()` succeed if strict: false with a `collection` property #7276
* fix(document): add `flattenMaps` option for toObject() #7274
* docs(document): document flattenMaps option #7274
* fix(populate): support populating individual subdoc path in document array #7273
* fix(populate): ensure `model` option overrides `refPath` #7273
* fix(map): don't call subdoc setters on init #7272
* fix(document): use internal get() helper instead of lodash.get to support `null` projection param #7271
* fix(document): continue running validateSync() for all elements in doc array after first error #6746
5.3.14 / 2018-11-27
===================
* docs(api): use `openUri()` instead of legacy `open()` #7277 [artemjackson](https://github.com/artemjackson)
* fix(document): don't mark date underneath single nested as modified if setting to string #7264
* fix(update): set timestamps on subdocs if not using $set with no overwrite #7261
* fix(document): use symbol instead of `__parent` so user code doesn't conflict #7230
* fix(mongoose): allow using `mongoose.model()` without context, like `import {model} from 'mongoose'` #3768
5.3.13 / 2018-11-20
===================
* fix: bump mongodb driver -> 3.1.10 #7266
* fix(populate): support setting a model as a `ref` #7253
* docs(schematype): add ref() function to document what is a valid `ref` path in a schematype #7253
* fix(array): clean modified subpaths when calling `splice()` #7249
* docs(compatibility): don't show Mongoose 4.11 as compatible with MongoDB 3.6 re: MongoDB's official compatibility table #7248 [a-harrison](https://github.com/a-harrison)
* fix(document): report correct validation error if doc array set to primitive #7242
* fix(mongoose): print warning when including server-side lib with jest jsdom environment #7240
5.3.12 / 2018-11-13
===================
* docs(compatibility): don't show Mongoose 4.11 as compatible with MongoDB 3.6 re: MongoDB's official compatibility table #7238 [a-harrison](https://github.com/a-harrison)
* fix(populate): use `instanceof` rather than class name for comparison #7237 [ivanseidel](https://github.com/ivanseidel)
* docs(api): make options show up as a nested list #7232
* fix(document): don't mark array as modified on init if doc array has default #7227
* docs(api): link to bulk write result object in `bulkWrite()` docs #7225
5.3.11 / 2018-11-09
===================
* fix(model): make parent pointers non-enumerable so they don't crash JSON.stringify() #7220
* fix(document): allow saving docs with nested props with '.' using `checkKeys: false` #7144
* docs(lambda): use async/await with lambda example #7019
5.3.10 / 2018-11-06
===================
* fix(discriminator): support reusing a schema for multiple discriminators #7200
* fix(cursor): handle `lean(false)` correctly with query cursors #7197
* fix(document): avoid manual populate if `ref` not set #7193
* fix(schema): handle schema without `.base` for browser build #7170
* docs: add further reading section
5.3.9 / 2018-11-02
==================
* fix: upgrade bson dep -> 1.1.0 to match mongodb-core #7213 [NewEraCracker](https://github.com/NewEraCracker)
* docs(api): fix broken anchor link #7210 [gfranco93](https://github.com/gfranco93)
* fix: don't set parent timestamps because a child has timestamps set to false #7203 #7202 [lineus](https://github.com/lineus)
* fix(document): run setter only once when doing `.set()` underneath a single nested subdoc #7196
* fix(document): surface errors in subdoc pre validate #7187
* fix(query): run default functions after hydrating the loaded document #7182
* fix(query): handle strictQuery: 'throw' with nested path correctly #7178
* fix(update): update timestamps on replaceOne() #7152
* docs(transactions): add example of aborting a transaction #7113
5.3.8 / 2018-10-30
==================
* fix: bump mongodb driver -> 3.1.8 to fix connecting to +srv uri with no credentials #7191 #6881 [lineus](https://github.com/lineus)
* fix(document): sets defaults correctly in child docs with projection #7159
* fix(mongoose): handle setting custom type on a separate mongoose global #7158
* fix: add unnecessary files to npmignore #7157
* fix(model): set session when creating new subdoc #7104
5.3.7 / 2018-10-26
==================
* fix(browser): fix buffer usage in browser build #7184 #7173 [lineus](https://github.com/lineus)
* fix(document): make depopulate() work on populate virtuals and unpopulated docs #7180 #6075 [lineus](https://github.com/lineus)
* fix(document): only pass properties as 2nd arg to custom validator if `propsParameter` set #7145
* docs(schematypes): add note about nested paths with `type` getting converted to mixed #7143
* fix(update): run update validators on nested doc when $set on an array #7135
* fix(update): copy exact errors from array subdoc validation into top-level update validator error #7135
5.3.6 / 2018-10-23
==================
* fix(cursor): fix undefined transforms error
5.3.5 / 2018-10-22
==================
* fix(model): make sure versionKey on `replaceOne()` always gets set at top level to prevent cast errors #7138
* fix(cursor): handle non-boolean lean option in `eachAsync()` #7137
* fix(update): correct cast update that overwrites a map #7111
* fix(schema): handle arrays of mixed correctly #7109
* fix(query): use correct path when getting schema for child timestamp update #7106
* fix(document): make `$session()` propagate sessions to child docs #7104
* fix(document): handle user setting `schema.options.strict = 'throw'` #7103
* fix(types): use core Node.js buffer prototype instead of safe-buffer because safe-buffer is broken for Node.js 4.x #7102
* fix(document): handle setting single doc with refPath to document #7070
* fix(model): handle array filters when updating timestamps for subdocs #7032
5.3.4 / 2018-10-15
==================
* fix(schema): make `add()` and `remove()` return the schema instance #7131 [lineus](https://github.com/lineus)
* fix(query): don't require passing model to `cast()` #7118
* fix: support `useFindAndModify` as a connection-level option #7110 [lineus](https://github.com/lineus)
* fix(populate): handle plus path projection with virtual populate #7050
* fix(schema): allow using ObjectId type as schema path type #7049
* docs(schematypes): elaborate on how schematypes relate to types #7049
* docs(deprecations): add note about gridstore deprecation #6922
* docs(guide): add storeSubdocValidationError option to guide #6802
5.3.3 / 2018-10-12
==================
* fix(document): enable storing mongoose validation error in MongoDB by removing `$isValidatorError` property #7127
* docs(api): clarify that aggregate triggers aggregate middleware #7126 [lineus](https://github.com/lineus)
* fix(connection): handle Model.init() when an index exists on schema + autoCreate == true #7122 [jesstelford](https://github.com/jesstelford)
* docs(middleware): explain how to switch between document and query hooks for `remove()` #7093
* docs(api): clean up encoding issues in SchemaType.prototype.validate docs #7091
* docs(schema): add schema types to api docs and update links on schematypes page #7080 #7076 [lineus](https://github.com/lineus)
* docs(model): expand model constructor docs with examples and `fields` param #7077
* docs(aggregate): remove incorrect description of noCursorTimeout and add description of aggregate options #7056
* docs: re-add array type to API docs #7027
* docs(connections): add note about `members.host` errors due to bad host names in replica set #7006
5.3.2 / 2018-10-07
==================
* fix(query): make sure to return correct result from `orFail()` #7101 #7099 [gsandorx](https://github.com/gsandorx)
* fix(schema): handle `{ timestamps: false }` correctly #7088 #7074 [lineus](https://github.com/lineus)
* docs: fix markdown in options.useCreateIndex documentation #7085 [Cyral](https://github.com/Cyral)
* docs(schema): correct field name in timestamps example #7082 [kizmo04](https://github.com/kizmo04)
* docs(migrating_to_5): correct markdown syntax #7078 [gwuah](https://github.com/gwuah)
* fix(connection): add useFindAndModify option in connect #7059 [NormanPerrin](https://github.com/NormanPerrin)
* fix(document): dont mark single nested path as modified if setting to the same value #7048
* fix(populate): use WeakMap to track lean populate models rather than leanPopulateSymbol #7026
* fix(mongoose): avoid unhandled rejection when `mongoose.connect()` errors with a callback #6997
* fix(mongoose): isolate Schema.Types between custom Mongoose instances #6933
5.3.1 / 2018-10-02
==================
* fix(ChangeStream): expose driver's `close()` function #7068 #7022 [lineus](https://github.com/lineus)
* fix(model): avoid printing warning if `_id` index is set to "hashed" #7053
* fix(populate): handle nested populate underneath lean array correctly #7052
* fix(update): make timestamps not crash on a null or undefined update #7041
* docs(schematypes+validation): clean up links from validation docs to schematypes docs #7040
* fix(model): apply timestamps to nested docs in bulkWrite() #7032
* docs(populate): rewrite refPath docs to be simpler and more direct #7013
* docs(faq): explain why destructuring imports are not supported in FAQ #7009
5.3.0 / 2018-09-28
==================
* feat(mongoose): support `mongoose.set('debug', WritableStream)` so you can pipe debug to stderr, file, or network #7018
* feat(query): add useNestedStrict option #6973 #5144 [lineus](https://github.com/lineus)
* feat(query): add getPopulatedPaths helper to Query.prototype #6970 #6677 [lineus](https://github.com/lineus)
* feat(model): add `createCollection()` helper to make transactions easier #6948 #6711 [Fonger](https://github.com/Fonger)
* feat(schema): add ability to do `schema.add(otherSchema)` to merge hooks, virtuals, etc. #6897
* feat(query): add `orFail()` helper that throws an error if no documents match `filter` #6841
* feat(mongoose): support global toObject and toJSON #6815
* feat(connection): add deleteModel() to remove a model from a connection #6813
* feat(mongoose): add top-level mongoose.ObjectId, mongoose.Decimal128 for easier schema declarations #6760
* feat(aggregate+query): support for/await/of (async iterators) #6737
* feat(mongoose): add global `now()` function that you can stub for testing timestamps #6728
* feat(schema): support `schema.pre(RegExp, fn)` and `schema.post(RegExp, fn)` #6680
* docs(query): add better docs for the `mongooseOptions()` function #6677
* feat(mongoose): add support for global strict object #6858
* feat(schema+mongoose): add autoCreate option to automatically create collections #6489
* feat(update): update timestamps on nested subdocs when using `$set` #4412
* feat(query+schema): add query `remove` hook and ability to switch between query `remove` and document `remove` middleware #3054
5.2.18 / 2018-09-27
===================
* docs(migrating_to_5): add note about overwriting filter properties #7030
* fix(query): correctly handle `select('+c')` if c is not in schema #7017
* fix(document): check path exists before checking for required #6974
* fix(document): retain user-defined key order on initial set with nested docs #6944
* fix(populate): handle multiple localFields + foreignFields using `localField: function() {}` syntax #5704
5.2.17 / 2018-09-21
===================
* docs(guide): clarify that Mongoose only increments versionKey on `save()` and add a workaround for `findOneAndUpdate()` #7038
* fix(model): correctly handle `createIndex` option to `ensureIndexes()` #7036 #6922 [lineus](https://github.com/lineus)
* docs(migrating_to_5): add a note about changing debug output from stderr to stdout #7034 #7018 [lineus](https://github.com/lineus)
* fix(query): add `setUpdate()` to allow overwriting update without changing op #7024 #7012 [lineus](https://github.com/lineus)
* fix(update): find top-level version key even if there are `$` operators in the update #7003
* docs(model+query): explain which operators `count()` supports that `countDocuments()` doesn't #6911
5.2.16 / 2018-09-19
===================
* fix(index): use dynamic require only when needed for better webpack support #7014 #7010 [jaydp17](https://github.com/jaydp17)
* fix(map): handle arrays of mixed maps #6995
* fix(populate): leave justOne as null if populating underneath a Mixed type #6985
* fix(populate): add justOne option to allow overriding any bugs with justOne #6985
* fix(query): add option to skip adding timestamps to an update #6980
* docs(model+schematype): improve docs about background indexes and init() #6966
* fix: bump mongodb -> 3.1.6 to allow connecting to srv url without credentials #6955 #6881 [lineus](https://github.com/lineus)
* fix(connection): allow specifying `useCreateIndex` at the connection level, overrides global-level #6922
* fix(schema): throw a helpful error if setting `ref` to an invalid value #6915
5.2.15 / 2018-09-15
===================
* fix(populate): handle virtual justOne correctly if it isn't set #6988
* fix(populate): consistently use lowercase `model` instead of `Model` so double-populating works with existing docs #6978
* fix(model): allow calling `Model.init()` again after calling `dropDatabase()` #6967
* fix(populate): find correct justOne when double-populating underneath an array #6798
* docs(webpack): make webpack docs use es2015 preset for correct libs and use acorn to test output is valid ES5 #6740
* fix(populate): add selectPopulatedPaths option to opt out of auto-adding `populate()`-ed fields to `select()` #6546
* fix(model): set timestamps on bulkWrite `insertOne` and `replaceOne` #5708
5.2.14 / 2018-09-09
===================
* docs: fix wording on promise docs to not imply queries only return promises #6983 #6982 [lineus](https://github.com/lineus)
* fix(map): throw TypeError if keys are not string #6956
* fix(document): ensure you can `validate()` a child doc #6931
* fix(populate): avoid cast error if refPath points to localFields with 2 different types #6870
* fix(populate): handle populating already-populated paths #6839
* fix(schematype): make ObjectIds handle refPaths when checking required #6714
* fix(model): set timestamps on bulkWrite() updates #5708
5.2.13 / 2018-09-04
===================
* fix(map): throw TypeError if keys are not string #6968 [Fonger](https://github.com/Fonger)
* fix(update): make array op casting work with strict:false and {} #6962 #6952 [lineus](https://github.com/lineus)
* fix(document): add doc.deleteOne(), doc.updateOne(), doc.replaceOne() re: deprecation warnings #6959 #6940 [lineus](https://github.com/lineus)
* docs(faq+schematypes): add note about map keys needing to be strings #6957 #6956 [lineus](https://github.com/lineus)
* fix(schematype): remove unused if statement #6950 #6949 [cacothi](https://github.com/cacothi)
* docs: add /docs/deprecations.html for dealing with MongoDB driver deprecation warnings #6922
* fix(populate): handle refPath where first element in array has no refPath #6913
* fix(mongoose): allow setting useCreateIndex option after creating a model but before initial connection succeeds #6890
* fix(updateValidators): ensure $pull validators always get an array #6889
5.2.12 / 2018-08-30
===================
* fix(document): disallow setting `constructor` and `prototype` if strict mode false
4.13.17 / 2018-08-30
====================
* fix(document): disallow setting `constructor` and `prototype` if strict mode false
5.2.11 / 2018-08-30
===================
* fix(document): disallow setting __proto__ if strict mode false
* fix(document): run document middleware on docs embedded in maps #6945 #6938 [Fonger](https://github.com/Fonger)
* fix(query): make castForQuery return a CastError #6943 #6927 [lineus](https://github.com/lineus)
* fix(query): use correct `this` scope when casting query with legacy 2dsphere pairs defined in schema #6939 #6937 [Fonger](https://github.com/Fonger)
* fix(document): avoid crash when calling `get()` on deeply nested subdocs #6929 #6925 [jakemccloskey](https://github.com/jakemccloskey)
* fix(plugins): make saveSubdocs execute child post save hooks _after_ the actual save #6926
* docs: add dbName to api docs for .connect() #6923 [p722](https://github.com/p722)
* fix(populate): convert to array when schema specifies array, even if doc doesn't have an array #6908
* fix(populate): handle `justOne` virtual populate underneath array #6867
* fix(model): dont set versionKey on upsert if it is already `$set` #5973
4.13.16 / 2018-08-30
====================
* fix(document): disallow setting __proto__ if strict mode false
* feat(error): backport adding modified paths to VersionError #6928 [freewil](https://github.com/freewil)
5.2.10 / 2018-08-27
===================
* fix: bump mongodb driver -> 3.1.4 #6920 #6903 #6884 #6799 #6741 [Fonger](https://github.com/Fonger)
* fix(model): track `session` option for `save()` as the document's `$session()` #6909
* fix(query): add Query.getOptions() helper #6907 [Fonger](https://github.com/Fonger)
* fix(document): ensure array atomics get cleared after save() #6900
* fix(aggregate): add missing redact and readConcern helpers #6895 [Fonger](https://github.com/Fonger)
* fix: add global option `mongoose.set('useCreateIndex', true)` to avoid ensureIndex deprecation warning #6890
* fix(query): use `projection` option to avoid deprecation warnings #6888 #6880 [Fonger](https://github.com/Fonger)
* fix(query): use `findOneAndReplace()` internally if using `overwrite: true` with `findOneAndUpdate()` #6888 [Fonger](https://github.com/Fonger)
* fix(document): ensure required cache gets cleared correctly between subsequent saves #6892
* fix(aggregate): support session chaining correctly #6886 #6885 [Fonger](https://github.com/Fonger)
* fix(query): use `projection` instead of `fields` internally for `find()` and `findOne()` to avoid deprecation warning #6880
* fix(populate): add `getters` option to opt in to calling getters on populate #6844
5.2.9 / 2018-08-17
==================
* fix(document): correctly propagate write concern options in save() #6877 [Fonger](https://github.com/Fonger)
* fix: upgrade mongodb driver -> 3.1.3 for numerous fixes #6869 #6843 #6692 #6670 [simllll](https://github.com/simllll)
* fix: correct `this` scope of default functions for DocumentArray and Array #6868 #6840 [Fonger](https://github.com/Fonger)
* fix(types): support casting JSON form of buffers #6866 #6863 [Fonger](https://github.com/Fonger)
* fix(query): get global runValidators option correctly #6865 #6578
* fix(query): add Query.prototype.setQuery() analogous to `getQuery()` #6855 #6854
* docs(connections): add note about the `family` option for IPv4 vs IPv6 and add port to example URIs #6784
* fix(query): get global runValidators option correctly #6578
4.13.15 / 2018-08-14
====================
* fix(mongoose): add global `usePushEach` option for easier Mongoose 4.x + MongoDB 3.6 #6858
* chore: fix flakey tests for 4.x #6853 [Fonger](https://github.com/Fonger)
* feat(error): add version number to VersionError #6852 [freewil](https://github.com/freewil)
5.2.8 / 2018-08-13
==================
* docs: update `execPopulate()` code example #6851 [WJakub](https://github.com/WJakub)
* fix(document): allow passing callback to `execPopulate()` #6851
* fix(populate): populate with undefined fields without error #6848 #6845 [Fonger](https://github.com/Fonger)
* docs(migrating_to_5): Add `objectIdGetter` option docs #6842 [jwalton](https://github.com/jwalton)
* chore: run lint in parallel and only on Node.js v10 #6836 [Fonger](https://github.com/Fonger)
* fix(populate): throw helpful error if refPath excluded in query #6834
* docs(migrating_to_5): add note about removing runSettersOnQuery #6832
* fix: use safe-buffer to avoid buffer deprecation errors in Node.js 10 #6829 [Fonger](https://github.com/Fonger)
* docs(query): fix broken links #6828 [yaynick](https://github.com/yaynick)
* docs(defaults): clarify that defaults only run on undefined #6827
* chore: fix flakey tests #6824 [Fonger](https://github.com/Fonger)
* docs: fix custom inspect function deprecation warning in Node.js 10 #6821 [yelworc](https://github.com/yelworc)
* fix(document): ensure subdocs get set to init state after save() so validators can run again #6818
* fix(query): make sure embedded query casting always throws a CastError #6803
* fix(document): ensure `required` function only gets called once when validating #6801
* docs(connections): note that you must specify port if using `useNewUrlParser: true` #6789
* fix(populate): support `options.match` in virtual populate schema definition #6787
* fix(update): strip out virtuals from updates if strict: 'throw' rather than returning an error #6731
5.2.7 / 2018-08-06
==================
* fix(model): check `expireAfterSeconds` option when diffing indexes in syncIndexes() #6820 #6819 [christopherhex](https://github.com/christopherhex)
* chore: fix some common test flakes in travis #6816 [Fonger](https://github.com/Fonger)
* chore: bump eslint and webpack to avoid bad versions of eslint-scope #6814
* test(model): add delay to session tests to improve pass rate #6811 [Fonger](https://github.com/Fonger)
* fix(model): support options in `deleteMany` #6810 [Fonger](https://github.com/Fonger)
* fix(query): don't use $each when pushing an array into an array #6809 [lineus](https://github.com/lineus)
* chore: bump mquery so eslint isn't a prod dependency #6800
* fix(populate): correctly get schema type when calling `populate()` on already populated path #6798
* fix(populate): propagate readConcern options in populate from parent query #6792 #6785 [Fonger](https://github.com/Fonger)
* docs(connection): add description of useNewUrlParser option #6789
* fix(query): make select('+path') a no-op if no select prop in schema #6785
* docs(schematype+validation): document using function syntax for custom validator message #6772
* fix(update): throw CastError if updating with `$inc: null` #6770
* fix(connection): throw helpful error when calling `createConnection(undefined)` #6763
5.2.6 / 2018-07-30
==================
* fix(document): don't double-call deeply nested custom getters when using `get()` #6779 #6637
* fix(query): upgrade mquery for readConcern() helper #6777
* docs(schematypes): clean up typos #6773 [sajadtorkamani](https://github.com/sajadtorkamani)
* refactor(browser): fix webpack warnings #6771 #6705
* fix(populate): make error reported when no `localField` specified catchable #6767
* docs(connection): use correct form in createConnection example #6766 [lineus](https://github.com/lineus)
* fix(connection): throw helpful error when using legacy `mongoose.connect()` syntax #6756
* fix(document): handle overwriting `$session` in `execPopulate()` #6754
* fix(query): propagate top-level session down to `populate()` #6754
* fix(aggregate): add `session()` helper for consistency with query api #6752
* fix(map): avoid infinite recursion when update overwrites a map #6750
* fix(model): be consistent about passing noop callback to mongoose.model() `init()` as well as db.model() #6707
5.2.5 / 2018-07-23
==================
* fix(boolean): expose `convertToTrue` and `convertToFalse` for custom boolean casting #6758
* docs(schematypes): add note about what values are converted to booleans #6758
* fix(document): fix(document): report castError when setting single nested doc to array #6753
* docs: prefix mongoose.Schema call with new operator #6751 [sajadtorkamani](https://github.com/sajadtorkamani)
* docs(query): add examples and links to schema writeConcern option for writeConcern helpers #6748
* docs(middleware): clarify that init middleware is sync #6747
* perf(model): create error rather than modifying stack for source map perf #6735
* fix(model): throw helpful error when passing object to aggregate() #6732
* fix(model): pass Model instance as context to applyGetters when calling getters for virtual populate #6726 [lineus](https://github.com/lineus)
* fix(documentarray): remove `isNew` and `save` listeners on CastError because otherwise they never get removed #6723
* docs(model+query): clarify when to use `countDocuments()` vs `estimatedDocumentCount()` #6713
* fix(populate): correctly set virtual nestedSchemaPath when calling populate() multiple times #6644
* docs(connections): add note about the `family` option for IPv4 vs IPv6 and add port to example URIs #6566
5.2.4 / 2018-07-16
==================
* docs: Model.insertMany rawResult option in api docs #6724 [lineus](https://github.com/lineus)
* docs: fix typo on migrating to 5 guide #6722 [iagowp](https://github.com/iagowp)
* docs: update doc about keepalive #6719 #6718 [simllll](https://github.com/simllll)
* fix: ensure debug mode doesn't crash with sessions #6712
* fix(document): report castError when setting single nested doc to primitive value #6710
* fix(connection): throw helpful error if using `new db.model(foo)(bar)` #6698
* fix(model): throw readable error with better stack trace when non-cb passed to $wrapCallback() #6640
5.2.3 / 2018-07-11
==================
* fix(populate): if a getter is defined on the localField, use it when populating #6702 #6618 [lineus](https://github.com/lineus)
* docs(schema): add example of nested aliases #6671
* fix(query): add `session()` function to queries to avoid positional argument mistakes #6663
* docs(transactions): use new session() helper to make positional args less confusing #6663
* fix(query+model+schema): add support for `writeConcern` option and writeConcern helpers #6620
* docs(guide): add `writeConcern` option and re-add description for `safe` option #6620
* docs(schema): fix broken API links #6619
* docs(connections): add information re: socketTimeoutMS and connectTimeoutMS #4789
5.2.2 / 2018-07-08
==================
* fix(model+query): add missing estimatedDocumentCount() function #6697
* docs(faq): improve array-defaults section #6695 [lineus](https://github.com/lineus)
* docs(model): fix countDocuments() docs, bad copy/paste from count() docs #6694 #6643
* fix(connection): add `startSession()` helper to connection and mongoose global #6689
* fix: upgrade mongodb driver -> 3.1.1 for countDocuments() fix #6688 #6666
* docs(compatibility): add MongoDB 4 range #6685
* fix(populate): add ability to define refPath as a function #6683 [lineus](https://github.com/lineus)
* docs: add rudimentary transactions guide #6672
* fix(update): make setDefaultsOnInsert handle nested subdoc updates with deeply nested defaults #6665
* docs: use latest acquit-ignore to handle examples that start with acquit:ignore:start #6657
* fix(validation): format `properties.message` as well as `message` #6621
5.2.1 / 2018-07-03
==================
* fix(connection): allow setting the mongodb driver's useNewUrlParser option, default to false #6656 #6648 #6647
* fix(model): only warn on custom _id index if index only has _id key #6650
5.2.0 / 2018-07-02
==================
* feat(model): add `countDocuments()` #6643
* feat(model): make ensureIndexes() fail if specifying an index on _id #6605
* feat(mongoose): add `objectIdGetter` option to remove ObjectId.prototype._id #6588
* feat: upgrade mongodb -> 3.1.0 for full MongoDB 4.0 support #6579
* feat(query): support `runValidators` as a global option #6578
* perf(schema): use WeakMap instead of array for schema stack #6503
* feat(model): decorate unique discriminator indexes with partialFilterExpressions #6347
* feat(model): add `syncIndexes()`, drops indexes that aren't in schema #6281
* feat(document): add default getter/setter if virtual doesn't have one #6262
* feat(discriminator): support discriminators on nested doc arrays #6202
* feat(update): add `Query.prototype.set()` #5770
5.1.8 / 2018-07-02
==================
* fix: don't throw TypeError if calling save() after original save() failed with push() #6638 [evanhenke](https://github.com/evanhenke)
* fix(query): add explain() helper and don't hydrate explain output #6625
* docs(query): fix `setOptions()` lists #6624
* docs: add geojson docs #6607
* fix: bump mongodb -> 3.0.11 to avoid cyclic dependency error with retryWrites #6109
5.1.7 / 2018-06-26
==================
* docs: add npm badge to readme #6623 [VFedyk](https://github.com/VFedyk)
* fix(document): don't throw parallel save error if post save hooks in parallel #6614 #6611 [lineus](https://github.com/lineus)
* fix(populate): allow dynamic ref to handle >1 model getModelsMapForPopulate #6613 #6612 [jimmytsao](https://github.com/jimmytsao)
* fix(document): handle `push()` on triple nested document array #6602
* docs(validation): improve update validator doc headers #6577 [joeytwiddle](https://github.com/joeytwiddle)
* fix(document): handle document arrays in `modifiedPaths()` with includeChildren option #5904
5.1.6 / 2018-06-19
==================
* fix: upgrade mongodb -> 3.0.10
* docs(model+document): clarify that `save()` returns `undefined` if passed a callback #6604 [lineus](https://github.com/lineus)
* fix(schema): apply alias when adding fields with .add() #6593
* docs: add full list of guides and streamline nav #6592
* docs(model): add `projection` option to `findOneAndUpdate()` #6590 [lineus](https://github.com/lineus)
* docs: support @static JSDoc declaration #6584
* fix(query): use boolean casting logic for $exists #6581
* fix(query): cast all $text options to correct values #6581
* fix(model): add support synchronous pre hooks for `createModel` #6552 [profbiss](https://github.com/profbiss)
* docs: add note about the `applyPluginsToDiscriminators` option #4965
5.1.5 / 2018-06-11
==================
* docs(guide): rework query helper example #6575 [lineus](https://github.com/lineus)
* fix(populate): handle virtual populate with embedded discriminator under single nested subdoc #6571
* docs: add string option to projections that call query select #6563 [lineus](https://github.com/lineus)
* style: use ES6 in collection.js #6560 [l33ds](https://github.com/l33ds)
* fix(populate): add virtual ref function ability getModelsMapForPopulate #6559 #6554 [lineus](https://github.com/lineus)
* docs(queries): fix link #6557 [sun1x](https://github.com/sun1x)
* fix(schema): rename indexes -> getIndexes to avoid webpack duplicate declaration #6547
* fix(document): support `toString()` as custom method #6538
* docs: add @instance for instance methods to be more compliant with JSDoc #6516 [treble-snake](https://github.com/treble-snake)
* fix(populate): avoid converting to map when using mongoose-deep-populate #6460
* docs(browser): create new browser docs page #6061
5.1.4 / 2018-06-04
==================
* docs(faq): add hr tags for parallel save error #6550 [lineus](https://github.com/lineus)
* docs(connection): fix broken link #6545 [iblamefish](https://github.com/iblamefish)
* fix(populate): honor subpopulate options #6539 #6528 [lineus](https://github.com/lineus)
* fix(populate): allow population of refpath under array #6537 #6509 [lineus](https://github.com/lineus)
* fix(query): dont treat $set the same as the other ops in update casting #6535 [lineus](https://github.com/lineus)
* fix: bump async -> 2.6.1 #6534 #6505 [lineus](https://github.com/lineus)
* fix: support using a function as validation error message #6530 [lucandrade](https://github.com/lucandrade)
* fix(populate): propagate `lean()` down to subpopulate #6498 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
* docs(lambda): add info on what happens if database does down between lambda function calls #6409
* fix(update): allow updating embedded discriminator path if discriminator key is in filter #5841
5.1.3 / 2018-05-28
==================
* fix(document): support set() on path underneath array embedded discriminator #6526
* chore: update lodash and nsp dev dependencies #6514 [ChristianMurphy](https://github.com/ChristianMurphy)
* fix(document): throw readable error when saving the same doc instance more than once in parallel #6511 #6456 #4064 [lineus](https://github.com/lineus)
* fix(populate): set correct nestedSchemaPath for virtual underneath embedded discriminator #6501 #6487 [lineus](https://github.com/lineus)
* docs(query): add section on promises and warning about not mixing promises and callbacks #6495
* docs(connection): add concrete example of connecting to multiple hosts #6492 [lineus](https://github.com/lineus)
* fix(populate): handle virtual populate under single nested doc under embedded discriminator #6488
* fix(schema): collect indexes from embedded discriminators for autoIndex build #6485
* fix(document): handle `doc.set()` underneath embedded discriminator #6482
* fix(document): handle set() on path under embedded discriminator with object syntax #6482
* fix(document): handle setting nested property to object with only non-schema properties #6436
4.13.14 / 2018-05-25
====================
* fix(model): handle retainKeyOrder option in findOneAndUpdate() #6484
5.1.2 / 2018-05-21
==================
* docs(guide): add missing SchemaTypes #6490 [distancesprinter](https://github.com/distancesprinter)
* fix(map): make MongooseMap.toJSON return a serialized object #6486 #6478 [lineus](https://github.com/lineus)
* fix(query): make CustomQuery inherit from model.Query for hooks #6483 #6455 [lineus](https://github.com/lineus)
* fix(document): prevent default falses from being skipped by $__dirty #6481 #6477 [lineus](https://github.com/lineus)
* docs(connection): document `useDb()` #6480
* fix(model): skip redundant clone in insertMany #6479 [d1manson](https://github.com/d1manson)
* fix(aggregate): let replaceRoot accept objects as well as strings #6475 #6474 [lineus](https://github.com/lineus)
* docs(model): clarify `emit()` in mapReduce and how map/reduce are run #6465
* fix(populate): flatten array to handle multi-level nested `refPath` #6457
* fix(date): cast small numeric strings as years #6444 [AbdelrahmanHafez](https://github.com/AbdelrahmanHafez)
* fix(populate): remove unmatched ids when using virtual populate on already hydrated document #6435
* fix(array): use custom array class to avoid clobbered property names #6431
* fix(model): handle hooks for custom methods that return promises #6385
4.13.13 / 2018-05-17
====================
* fix(update): stop clobbering $in when casting update #6441 #6339
* fix: upgrade async -> 2.6.0 re: security warning
5.1.1 / 2018-05-14
==================
* docs(schema): add notes in api and guide about schema.methods object #6470 #6440 [lineus](https://github.com/lineus)
* fix(error): add modified paths to VersionError #6464 #6433 [paglias](https://github.com/paglias)
* fix(populate): only call populate with full param signature when match is not present #6458 #6451 [lineus](https://github.com/lineus)
* docs: fix geoNear link in migration guide #6450 [kawache](https://github.com/kawache)
* fix(discriminator): throw readable error when `create()` with a non-existent discriminator key #6434
* fix(populate): add `retainNullValues` option to avoid stripping out null keys #6432
* fix(populate): handle populate in embedded discriminators underneath nested paths #6411
* docs(model): add change streams and ToC, make terminology more consistent #5888
5.1.0 / 2018-05-10
==================
* feat(ObjectId): add `_id` getter so you can get a usable id whether or not the path is populated #6415 #6115
* feat(model): add Model.startSession() #6362
* feat(document): add doc.$session() and set session on doc after query #6362
* feat: add Map type that supports arbitrary keys #6287 #681
* feat: add `cloneSchemas` option to mongoose global to opt in to always cloning schemas before use #6274
* feat(model): add `findOneAndDelete()` and `findByIdAndDelete()` #6164
* feat(document): support `$ignore()` on single nested and array subdocs #6152
* feat(document): add warning about calling `save()` on subdocs #6152
* fix(model): make `save()` use `updateOne()` instead of `update()` #6031
* feat(error): add version number to VersionError #5966
* fix(query): allow `[]` as a value for `$in` when casting #5913
* fix(document): avoid running validators on single nested paths if only a child path is modified #5885
* feat(schema): print warning if method conflicts with mongoose internals #5860
5.0.18 / 2018-05-09
===================
* fix(update): stop clobbering $in when casting update #6441 #6339 [lineus](https://github.com/lineus)
* fix: upgrade mongodb driver -> 3.0.8 to fix session issue #6437 #6357 [simllll](https://github.com/simllll)
* fix: upgrade bson -> 1.0.5 re: https://snyk.io/vuln/npm:bson:20180225 #6423 [ChristianMurphy](https://github.com/ChristianMurphy)
* fix: look for `valueOf()` when casting to Decimal128 #6419 #6418 [lineus](https://github.com/lineus)
* fix: populate array of objects with space separated paths #6414 [lineus](https://github.com/lineus)
* test: add coverage for `mongoose.pluralize()` #6412 [FastDeath](https://github.com/FastDeath)
* fix(document): avoid running default functions on init() if path has value #6410
* fix(document): allow saving document with `null` id #6406
* fix: prevent casting of populated docs in document.init #6390 [lineus](https://github.com/lineus)
* fix: remove `toHexString()` helper that was added in 5.0.15 #6359
5.0.17 / 2018-04-30
===================
* docs(migration): certain chars in passwords may cause connection failures #6401 [markstos](https://github.com/markstos)
* fix(document): don't throw when `push()` on a nested doc array #6398
* fix(model): apply hooks to custom methods if specified #6385
* fix(schema): support opting out of one timestamp field but not the other for `insertMany()` #6381
* fix(documentarray): handle `required: true` within documentarray definition #6364
* fix(document): ensure `isNew` is set before default functions run on init #3793
5.0.16 / 2018-04-23
===================
* docs(api): sort api methods based on their string property #6374 [lineus](https://github.com/lineus)
* docs(connection): fix typo in `createCollection()` #6370 [mattc41190](https://github.com/mattc41190)
* docs(document): remove vestigial reference to `numAffected` #6367 [ekulabuhov](https://github.com/ekulabuhov)
* docs(schema): fix typo #6366 [dhritzkiv](https://github.com/dhritzkiv)
* docs(schematypes): add missing `minlength` and `maxlength` docs #6365 [treble-snake](https://github.com/treble-snake)
* docs(queries): fix formatting #6360 [treble-snake](https://github.com/treble-snake)
* docs(api): add cursors to API docs #6353 #6344 [lineus](https://github.com/lineus)
* docs(aggregate): remove reference to non-existent `.select()` method #6346
* fix(update): handle `required` array with update validators and $pull #6341
* fix(update): avoid setting __v in findOneAndUpdate if it is `$set` #5973
5.0.15 / 2018-04-16
===================
* fix: add ability for casting from number to decimal128 #6336 #6331 [lineus](https://github.com/lineus)
* docs(middleware): enumerate the ways to error out in a hook #6315
* fix(document): respect schema-level depopulate option for toObject() #6313
* fix: bump mongodb driver -> 3.0.6 #6310
* fix(number): check for `valueOf()` function to support Decimal.js #6306 #6299 [lineus](https://github.com/lineus)
* fix(query): run array setters on query if input value is an array #6277
* fix(versioning): don't require matching version when using array.pull() #6190
* fix(document): add `toHexString()` function so you don't need to check whether a path is populated to get an id #6115
5.0.14 / 2018-04-09
===================
* fix(schema): clone aliases and alternative option syntax correctly
* fix(query): call utils.toObject in query.count like in query.find #6325 [lineus](https://github.com/lineus)
* docs(populate): add middleware examples #6320 [BorntraegerMarc](https://github.com/BorntraegerMarc)
* docs(compatibility): fix dead link #6319 [lacivert](https://github.com/lacivert)
* docs(api): fix markdown parsing for parameters #6318 #6314 [lineus](https://github.com/lineus)
* fix(populate): handle space-delimited paths in array populate #6296 #6284 [lineus](https://github.com/lineus)
* fix(populate): support basic virtual populate underneath embedded discriminators #6273
5.0.13 / 2018-04-05
===================
* docs(faq): add middleware to faq arrow function warning #6309 [lineus](https://github.com/lineus)
* docs(schema): add example to loadClass() docs #6308
* docs: clean up misc typos #6304 [sfrieson](https://github.com/sfrieson)
* fix(document): apply virtuals when calling `toJSON()` on a nested path #6294
* refactor(connection): use `client.db()` syntax rather than double-parsing the URI #6292 #6286
* docs: document new behavior of required validator for arrays #6288 [daltones](https://github.com/daltones)
* fix(schema): treat set() options as user-provided options #6274
* fix(schema): clone discriminators correctly #6274
* fix(update): make setDefaultsOnInsert not create subdoc if only default is id #6269
* docs(discriminator): clarify 3rd argument to Model.discriminator() #2596
5.0.12 / 2018-03-27
===================
* docs(query): updating model name in query API docs #6280 [lineus](https://github.com/lineus)
* docs: fix typo in tests #6275 [styler](https://github.com/styler)
* fix: add missing `.hint()` to aggregate #6272 #6251 [lineus](https://github.com/lineus)
* docs(api): add headers to each API docs section for easer nav #6261
* fix(query): ensure hooked query functions always run on next tick for chaining #6250
* fix(populate): ensure populated array not set to null if it isn't set #6245
* fix(connection): set readyState to disconnected if initial connection fails #6244 #6131
* docs(model): make `create()` params show up correctly in docs #6242
* fix(model): make error handlers work with MongoDB server errors and `insertMany()` #6228
* fix(browser): ensure browser document builds defaults for embedded arrays correctly #6175
* fix(timestamps): set timestamps when using `updateOne()` and `updateMany()` #6282 [gualopezb](https://github.com/gualopezb)
5.0.11 / 2018-03-19
===================
* fix(update): handle $pull with $in in update validators #6240
* fix(query): don't convert undefined to null when casting so driver `ignoreUndefined` option works #6236
* docs(middleware): add example of using async/await with middleware #6235
* fix(populate): apply justOne option before `completeMany()` so it works with lean() #6234
* fix(query): ensure errors in user callbacks aren't caught in init #6195 #6178
* docs(connections): document dbName option for Atlas connections #6179
* fix(discriminator): make child schema nested paths overwrite parent schema paths #6076
4.13.12 / 2018-03-13
====================
* fix(document): make virtual get() return undefined instead of null if no getters #6223
* docs: fix url in useMongoClient error message #6219 #6217 [lineus](https://github.com/lineus)
* fix(discriminator): don't copy `discriminators` property from base schema #6122 #6064
5.0.10 / 2018-03-12
===================
* docs(schematype): add notes re: running setters on queries #6209
* docs: fix typo #6208 [kamagatos](https://github.com/kamagatos)
* fix(query): only call setters once on query filter props for findOneAndUpdate and findOneAndRemove #6203
* docs: elaborate on connection string changes in migration guide #6193
* fix(document): skip applyDefaults if subdoc is null #6187
* docs: fix schematypes docs and link to them #6176
* docs(faq): add FAQs re: array defaults and casting aggregation pipelines #6184 #6176 #6170 [lineus](https://github.com/lineus)
* fix(document): ensure primitive defaults are set and built-in default functions run before setters #6155
* fix(query): handle single embedded embedded discriminators in castForQuery #6027
5.0.9 / 2018-03-05
==================
* perf: bump mongodb -> 3.0.4 to fix SSL perf issue #6065
5.0.8 / 2018-03-03
==================
* docs: remove obsolete references to `emitIndexErrors` #6186 [isaackwan](https://github.com/isaackwan)
* fix(query): don't cast findOne() until exec() so setters don't run twice #6157
* fix: remove document_provider.web.js file #6186
* fix(discriminator): support custom discriminator model names #6100 [wentout](https://github.com/wentout)
* fix: support caching calls to `useDb()` #6036 [rocketspacer](https://github.com/rocketspacer)
* fix(query): add omitUndefined option so setDefaultsOnInsert can kick in on undefined #6034
* fix: upgrade mongodb -> 3.0.3 for reconnectTries: 0 blocking process exit fix #6028