From ef1a4ff21d569456623082882381dcd2e71e07fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:08:16 +0000 Subject: [PATCH 01/19] chore(deps): bump actions/checkout from 4.1.6 to 4.1.7 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/a5ac7e51b41094c92402da3b24376905380afc29...692973e3d937129bcbf40652eb9f2f61becf3332) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/benchmark.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/documentation.yml | 4 ++-- .github/workflows/test.yml | 10 +++++----- .github/workflows/tidelift-alignment.yml | 2 +- .github/workflows/tsd.yml | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7f907742423..10df11dc592 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-20.04 name: Benchmark TypeScript Types steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 - name: Setup node diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ebec4f60e06..efa77ce7fa8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 8596c0348b4..0fcf2297d28 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest name: Lint Markdown files steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-20.04 name: Test Generating Docs steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: git fetch --depth=1 --tags # download all tags for documentation - name: Setup node diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 90e47fc07e1..d6ff049078a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest name: Lint JS-Files steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 @@ -58,7 +58,7 @@ jobs: MONGOMS_PREFER_GLOBAL_PATH: 1 FORCE_COLOR: true steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 @@ -94,7 +94,7 @@ jobs: MONGOMS_PREFER_GLOBAL_PATH: 1 FORCE_COLOR: true steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: @@ -122,7 +122,7 @@ jobs: env: FORCE_COLOR: true steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: @@ -139,6 +139,6 @@ jobs: contents: read steps: - name: Check out repo - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Dependency review uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/tidelift-alignment.yml b/.github/workflows/tidelift-alignment.yml index f3a213d1d8d..c151d9114ce 100644 --- a/.github/workflows/tidelift-alignment.yml +++ b/.github/workflows/tidelift-alignment.yml @@ -15,7 +15,7 @@ jobs: if: github.repository == 'Automattic/mongoose' steps: - name: Checkout - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: diff --git a/.github/workflows/tsd.yml b/.github/workflows/tsd.yml index e7865152638..cc3d045454d 100644 --- a/.github/workflows/tsd.yml +++ b/.github/workflows/tsd.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest name: Lint TS-Files steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest name: Test Typescript Types steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 From 4c956fc4cc6771caf3feaff4226a791f91219242 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:22:00 +0000 Subject: [PATCH 02/19] chore(deps-dev): bump typescript from 5.4.5 to 5.5.3 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.4.5 to 5.5.3. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](https://github.com/Microsoft/TypeScript/compare/v5.4.5...v5.5.3) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3fce3440e94..34d0c2455b7 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "sinon": "18.0.0", "stream-browserify": "3.0.0", "tsd": "0.31.0", - "typescript": "5.4.5", + "typescript": "5.5.3", "uuid": "9.0.1", "webpack": "5.91.0" }, From adc7f61095bfb462758747806a5a24e7860c3a57 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:22:54 +0000 Subject: [PATCH 03/19] chore(deps-dev): bump mongodb-memory-server from 9.3.0 to 9.4.0 Bumps [mongodb-memory-server](https://github.com/nodkz/mongodb-memory-server/tree/HEAD/packages/mongodb-memory-server) from 9.3.0 to 9.4.0. - [Release notes](https://github.com/nodkz/mongodb-memory-server/releases) - [Changelog](https://github.com/nodkz/mongodb-memory-server/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodkz/mongodb-memory-server/commits/v9.4.0/packages/mongodb-memory-server) --- updated-dependencies: - dependency-name: mongodb-memory-server dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3fce3440e94..8a934560064 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "mkdirp": "^3.0.1", "mocha": "10.4.0", "moment": "2.x", - "mongodb-memory-server": "9.3.0", + "mongodb-memory-server": "9.4.0", "ncp": "^2.0.0", "nyc": "15.1.0", "pug": "3.0.3", From f9f9cf824c09eac55509de800fd803e8a2937daf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:24:06 +0000 Subject: [PATCH 04/19] chore(deps-dev): bump @babel/core from 7.24.6 to 7.24.7 Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.24.6 to 7.24.7. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.24.7/packages/babel-core) --- updated-dependencies: - dependency-name: "@babel/core" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3fce3440e94..5c4ff7f5502 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "sift": "17.1.3" }, "devDependencies": { - "@babel/core": "7.24.6", + "@babel/core": "7.24.7", "@babel/preset-env": "7.24.6", "@typescript-eslint/eslint-plugin": "^6.2.1", "@typescript-eslint/parser": "^6.2.1", From c2cdb80f1b7d902d32456eab451a3255fbdfc2e0 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 2 Jul 2024 15:08:51 -0400 Subject: [PATCH 05/19] types: correct `this` for `validate.validator` schematype option Fix #14696 --- test/types/schema.test.ts | 46 ++++++++++++++++++++++++++++++++++++++- types/schematypes.d.ts | 2 +- types/validation.d.ts | 21 +++++++----------- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/test/types/schema.test.ts b/test/types/schema.test.ts index bbbcdd5d71f..9dab60d2022 100644 --- a/test/types/schema.test.ts +++ b/test/types/schema.test.ts @@ -18,7 +18,8 @@ import { SchemaType, Types, Query, - model + model, + ValidateOpts } from 'mongoose'; import { expectType, expectError, expectAssignable } from 'tsd'; import { ObtainDocumentPathType, ResolvePathType } from '../../types/inferschematype'; @@ -1511,3 +1512,46 @@ function gh13772() { const doc = new TestModel(); expectAssignable(doc.toObject()); } + +function gh14696() { + interface User { + name: string; + isActive: boolean; + isActiveAsync: boolean; + } + + const x: ValidateOpts = { + validator(v: any) { + expectAssignable(this); + return !v || this.name === 'super admin'; + } + }; + + const userSchema = new Schema({ + name: { + type: String, + required: [true, 'Name on card is required'] + }, + isActive: { + type: Boolean, + default: false, + validate: { + validator(v: any) { + expectAssignable(this); + return !v || this.name === 'super admin'; + } + } + }, + isActiveAsync: { + type: Boolean, + default: false, + validate: { + async validator(v: any) { + expectAssignable(this); + return !v || this.name === 'super admin'; + } + } + } + }); + +} diff --git a/types/schematypes.d.ts b/types/schematypes.d.ts index 778b83c7ad5..b7f1fc733b9 100644 --- a/types/schematypes.d.ts +++ b/types/schematypes.d.ts @@ -60,7 +60,7 @@ declare module 'mongoose' { alias?: string | string[]; /** Function or object describing how to validate this schematype. See [validation docs](https://mongoosejs.com/docs/validation.html). */ - validate?: SchemaValidator | AnyArray>; + validate?: SchemaValidator | AnyArray>; /** Allows overriding casting logic for this individual path. If a string, the given string overwrites Mongoose's default cast error message. */ cast?: string | diff --git a/types/validation.d.ts b/types/validation.d.ts index 488ead7e588..811d86f9262 100644 --- a/types/validation.d.ts +++ b/types/validation.d.ts @@ -1,6 +1,6 @@ declare module 'mongoose' { - type SchemaValidator = RegExp | [RegExp, string] | Function | [Function, string] | ValidateOpts | ValidateOpts[]; + type SchemaValidator = ValidateOpts; // RegExp | [RegExp, string] | Function | [Function, string] | ValidateOpts | ValidateOpts[]; interface ValidatorProps { path: string; @@ -13,23 +13,18 @@ declare module 'mongoose' { (props: ValidatorProps): string; } - interface ValidateFn { - (value: T, props?: ValidatorProps & Record): boolean; - } - - interface LegacyAsyncValidateFn { - (value: T, done: (result: boolean) => void): void; - } + type ValidateFn = + (this: EnforcedDocType, value: any, props?: ValidatorProps & Record) => boolean; - interface AsyncValidateFn { - (value: T, props?: ValidatorProps & Record): Promise; - } + type AsyncValidateFn = + (this: EnforcedDocType, value: any, props?: ValidatorProps & Record) => Promise; - interface ValidateOpts { + interface ValidateOpts { msg?: string; message?: string | ValidatorMessageFn; type?: string; - validator: ValidateFn | LegacyAsyncValidateFn | AsyncValidateFn; + validator: ValidateFn + | AsyncValidateFn; propsParameter?: boolean; } } From 0a43d21e7ba81c9773bf1ad446a5da21ed818053 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 2 Jul 2024 15:15:12 -0400 Subject: [PATCH 06/19] undo accidentally committed test changes --- types/validation.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/validation.d.ts b/types/validation.d.ts index 811d86f9262..3310d954435 100644 --- a/types/validation.d.ts +++ b/types/validation.d.ts @@ -1,6 +1,6 @@ declare module 'mongoose' { - type SchemaValidator = ValidateOpts; // RegExp | [RegExp, string] | Function | [Function, string] | ValidateOpts | ValidateOpts[]; + type SchemaValidator = RegExp | [RegExp, string] | Function | [Function, string] | ValidateOpts | ValidateOpts[]; interface ValidatorProps { path: string; From 56ba9a3c8df8dee878ec038f8774c3f5d844047b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 21:53:28 +0000 Subject: [PATCH 07/19] chore(deps-dev): bump webpack from 5.91.0 to 5.92.1 Bumps [webpack](https://github.com/webpack/webpack) from 5.91.0 to 5.92.1. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.91.0...v5.92.1) --- updated-dependencies: - dependency-name: webpack dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b383ae36df..3a4407536cd 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "tsd": "0.31.0", "typescript": "5.5.3", "uuid": "9.0.1", - "webpack": "5.91.0" + "webpack": "5.92.1" }, "directories": { "lib": "./lib/mongoose" From 8ce77f2782642e49169780bf12a4f5207e09c53e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 21:53:58 +0000 Subject: [PATCH 08/19] chore(deps-dev): bump mocha from 10.4.0 to 10.6.0 Bumps [mocha](https://github.com/mochajs/mocha) from 10.4.0 to 10.6.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v10.4.0...v10.6.0) --- updated-dependencies: - dependency-name: mocha dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b383ae36df..7be4f9134f5 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "markdownlint-cli2": "^0.13.0", "marked": "4.3.0", "mkdirp": "^3.0.1", - "mocha": "10.4.0", + "mocha": "10.6.0", "moment": "2.x", "mongodb-memory-server": "9.4.0", "ncp": "^2.0.0", From f6c7356ce84ee4b2cd6d3acc20ce8f1ed5f30999 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:04:12 +0000 Subject: [PATCH 09/19] chore(deps-dev): bump uuid from 9.0.1 to 10.0.0 Bumps [uuid](https://github.com/uuidjs/uuid) from 9.0.1 to 10.0.0. - [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md) - [Commits](https://github.com/uuidjs/uuid/compare/v9.0.1...v10.0.0) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fcdfe5da787..ca16347589b 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "stream-browserify": "3.0.0", "tsd": "0.31.0", "typescript": "5.5.3", - "uuid": "9.0.1", + "uuid": "10.0.0", "webpack": "5.92.1" }, "directories": { From 58adabd473a09625e8a9a995eeabf4adcd04595f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:04:39 +0000 Subject: [PATCH 10/19] chore(deps-dev): bump tsd from 0.31.0 to 0.31.1 Bumps [tsd](https://github.com/tsdjs/tsd) from 0.31.0 to 0.31.1. - [Release notes](https://github.com/tsdjs/tsd/releases) - [Commits](https://github.com/tsdjs/tsd/compare/v0.31.0...v0.31.1) --- updated-dependencies: - dependency-name: tsd dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fcdfe5da787..ee14b512e06 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "q": "1.5.1", "sinon": "18.0.0", "stream-browserify": "3.0.0", - "tsd": "0.31.0", + "tsd": "0.31.1", "typescript": "5.5.3", "uuid": "9.0.1", "webpack": "5.92.1" From 0d92a7a53cc7d49f49d64484b4566f59a8e860c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:05:35 +0000 Subject: [PATCH 11/19] chore(deps-dev): bump @babel/preset-env from 7.24.6 to 7.24.7 Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.24.6 to 7.24.7. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.24.7/packages/babel-preset-env) --- updated-dependencies: - dependency-name: "@babel/preset-env" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fcdfe5da787..0f96db663a2 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "devDependencies": { "@babel/core": "7.24.7", - "@babel/preset-env": "7.24.6", + "@babel/preset-env": "7.24.7", "@typescript-eslint/eslint-plugin": "^6.2.1", "@typescript-eslint/parser": "^6.2.1", "acquit": "1.3.0", From f530400e86e558ecc6cbb5e7c4f74bdbfdd8659d Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 3 Jul 2024 11:38:39 -0400 Subject: [PATCH 12/19] docs(model): note that `insertMany()` with `lean` skips applying defaults Fix #14698 --- lib/model.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/model.js b/lib/model.js index a94e3caff64..f30a00a20ba 100644 --- a/lib/model.js +++ b/lib/model.js @@ -3122,16 +3122,23 @@ Model.startSession = function() { * * #### Example: * - * await Movies.insertMany([ + * const docs = await Movies.insertMany([ * { name: 'Star Wars' }, * { name: 'The Empire Strikes Back' } * ]); + * docs[0].name; // 'Star Wars' + * + * // Return raw result from MongoDB + * const result = await Movies.insertMany([ + * { name: 'Star Wars' }, + * { name: 'The Empire Strikes Back' } + * ], { rawResult: true }); * * @param {Array|Object|*} doc(s) * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#insertMany) * @param {Boolean} [options.ordered=true] if true, will fail fast on the first error encountered. If false, will insert all the documents it can and report errors later. An `insertMany()` with `ordered = false` is called an "unordered" `insertMany()`. * @param {Boolean} [options.rawResult=false] if false, the returned promise resolves to the documents that passed mongoose document validation. If `true`, will return the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/InsertManyResult.html) with a `mongoose` property that contains `validationErrors` and `results` if this is an unordered `insertMany`. - * @param {Boolean} [options.lean=false] if `true`, skips hydrating the documents. This means Mongoose will **not** cast or validate any of the documents passed to `insertMany()`. This option is useful if you need the extra performance, but comes with data integrity risk. Consider using with [`castObject()`](https://mongoosejs.com/docs/api/model.html#Model.castObject()). + * @param {Boolean} [options.lean=false] if `true`, skips hydrating the documents. This means Mongoose will **not** cast, validate, or apply defaults to any of the documents passed to `insertMany()`. This option is useful if you need the extra performance, but comes with data integrity risk. Consider using with [`castObject()`](https://mongoosejs.com/docs/api/model.html#Model.castObject()) and [`applyDefaults()`](https://mongoosejs.com/docs/api/model.html#Model.applyDefaults()). * @param {Number} [options.limit=null] this limits the number of documents being processed (validation/casting) by mongoose in parallel, this does **NOT** send the documents in batches to MongoDB. Use this option if you're processing a large number of documents and your app is running out of memory. * @param {String|Object|Array} [options.populate=null] populates the result documents. This option is a no-op if `rawResult` is set. * @param {Boolean} [options.throwOnValidationError=false] If true and `ordered: false`, throw an error if one of the operations failed validation, but all valid operations completed successfully. From 83d7630310532bc7c8da6ad16ea47c518acffded Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Fri, 5 Jul 2024 12:37:03 -0400 Subject: [PATCH 13/19] chore: release 8.4.5 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 707999f7c6d..1da05718451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +8.4.5 / 2024-07-05 +================== + * types: correct this for validate.validator schematype option #14720 #14696 + * docs(model): note that insertMany() with lean skips applying defaults #14723 #14698 + 8.4.4 / 2024-06-25 ================== * perf: avoid unnecesary get() call and use faster approach for converting to string #14673 #14394 diff --git a/package.json b/package.json index 28e8e1c04a4..d2fffca8d75 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongoose", "description": "Mongoose MongoDB ODM", - "version": "8.4.4", + "version": "8.4.5", "author": "Guillermo Rauch ", "keywords": [ "mongodb", From 5932c0d24ba8ebeec2d44f8bf4753e0c799d391c Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sat, 6 Jul 2024 12:08:49 +0200 Subject: [PATCH 14/19] chore(dev-deps): bump @typescript-eslint/* from 6.2.1 to 6.21.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d2fffca8d75..5962a9ad81f 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ "devDependencies": { "@babel/core": "7.24.7", "@babel/preset-env": "7.24.7", - "@typescript-eslint/eslint-plugin": "^6.2.1", - "@typescript-eslint/parser": "^6.2.1", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", "acquit": "1.3.0", "acquit-ignore": "0.2.1", "acquit-require": "0.1.1", From b9e6501a75f15909a0650797a7ae8ed7ba331bbe Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sat, 6 Jul 2024 12:12:26 +0200 Subject: [PATCH 15/19] chore(dev-deps): bump axios from 1.1.3 to 1.7.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5962a9ad81f..5378dd31ce0 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "acquit-ignore": "0.2.1", "acquit-require": "0.1.1", "assert-browserify": "2.0.0", - "axios": "1.1.3", + "axios": "1.7.2", "babel-loader": "8.2.5", "broken-link-checker": "^0.7.8", "buffer": "^5.6.0", From 808bdc91c9a178098e68d33ab789c30a728b4384 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sat, 6 Jul 2024 12:14:06 +0200 Subject: [PATCH 16/19] chore(dev-deps): bump express from 4.18.1 to 4.19.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5378dd31ce0..57c5467177a 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "eslint": "8.57.0", "eslint-plugin-markdown": "^5.0.0", "eslint-plugin-mocha-no-only": "1.2.0", - "express": "^4.18.1", + "express": "^4.19.2", "fs-extra": "~11.2.0", "highlight.js": "11.8.0", "lodash.isequal": "4.5.0", From cb96aa50b0eeff02dc7571c0e5f2dd2942f39eb7 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sat, 6 Jul 2024 12:16:12 +0200 Subject: [PATCH 17/19] chore(dev-deps): bump highlight.js from 11.8.0 to 11.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 57c5467177a..ed30394b983 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "eslint-plugin-mocha-no-only": "1.2.0", "express": "^4.19.2", "fs-extra": "~11.2.0", - "highlight.js": "11.8.0", + "highlight.js": "11.9.0", "lodash.isequal": "4.5.0", "lodash.isequalwith": "4.4.0", "markdownlint-cli2": "^0.13.0", From 13f96a44be9930c6d31aecc4adcac5c38dedd10c Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sat, 6 Jul 2024 12:19:33 +0200 Subject: [PATCH 18/19] chore(dev-deps): set moment to use a consistent version like the rest of the dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed30394b983..1eee432aa61 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "marked": "4.3.0", "mkdirp": "^3.0.1", "mocha": "10.6.0", - "moment": "2.x", + "moment": "2.30.1", "mongodb-memory-server": "9.4.0", "ncp": "^2.0.0", "nyc": "15.1.0", From 8a1018677c9a47b81b3f464a5880da49ee6130ff Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sat, 6 Jul 2024 14:29:16 -0400 Subject: [PATCH 19/19] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1eee432aa61..6dac516c46e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "acquit-ignore": "0.2.1", "acquit-require": "0.1.1", "assert-browserify": "2.0.0", - "axios": "1.7.2", + "axios": "1.1.3", "babel-loader": "8.2.5", "broken-link-checker": "^0.7.8", "buffer": "^5.6.0",