diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index eb32422b89b..cd542950b49 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 with: fetch-depth: 0 - name: Setup node diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 78bf9c9c140..234108b30be 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index f20394fdb22..9329c6c2b02 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - 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 9d8858be7e8..c5be0645cab 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: Dependency review uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/tidelift-alignment.yml b/.github/workflows/tidelift-alignment.yml index e2498c40e08..e2baae64c52 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - 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 1eb30cf6862..6cd4afafe59 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: Setup node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f6b8afa365..9f4783a393f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +8.2.4 / 2024-03-28 +================== + * types(query): bring "getFilter" and "getQuery" in-line with "find" and other types #14463 [noseworthy](https://github.com/noseworthy) + * types(schema): re-export the defintion for SearchIndexDescription #14464 + * docs: removed unused hook from docs #14461 [bernardarhia](https://github.com/bernardarhia) + 8.2.3 / 2024-03-21 ================== * fix(schema): avoid returning string 'nested' as schematype #14453 #14443 #14435 diff --git a/docs/middleware.md b/docs/middleware.md index f7c8c0bb4ff..41440c9a6bc 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -52,7 +52,6 @@ In query middleware functions, `this` refers to the query. * [findOneAndUpdate](api/query.html#query_Query-findOneAndUpdate) * [remove](api/model.html#model_Model-remove) * [replaceOne](api/query.html#query_Query-replaceOne) -* [update](api/query.html#query_Query-update) * [updateOne](api/query.html#query_Query-updateOne) * [updateMany](api/query.html#query_Query-updateMany) * [validate](validation.html#update-validators) @@ -539,15 +538,14 @@ also define a post `update()` hook that will catch MongoDB duplicate key errors. ```javascript -// The same E11000 error can occur when you call `update()` -// This function **must** take 3 parameters. If you use the -// `passRawResult` function, this function **must** take 4 -// parameters -schema.post('update', function(error, res, next) { +// The same E11000 error can occur when you call `updateOne()` +// This function **must** take 4 parameters. + +schema.post('updateOne', function(passRawResult, error, res, next) { if (error.name === 'MongoServerError' && error.code === 11000) { next(new Error('There was a duplicate key error')); } else { - next(); // The `update()` call will still error out. + next(); // The `updateOne()` call will still error out. } }); @@ -555,7 +553,7 @@ const people = [{ name: 'Axl Rose' }, { name: 'Slash' }]; await Person.create(people); // Throws "There was a duplicate key error" -await Person.update({ name: 'Slash' }, { $set: { name: 'Axl Rose' } }); +await Person.updateOne({ name: 'Slash' }, { $set: { name: 'Axl Rose' } }); ``` Error handling middleware can transform an error, but it can't remove the diff --git a/docs/source/api.js b/docs/source/api.js index 092f93668c2..e398164056a 100644 --- a/docs/source/api.js +++ b/docs/source/api.js @@ -310,7 +310,7 @@ function processFile(props) { ctx.type = 'function'; ctx.isStatic = true; ctx.name = tag.string; - // extra parameter to make function definitions independant of where "@function" is defined + // extra parameter to make function definitions independent of where "@function" is defined // like "@static" could have overwritten "ctx.string" again if defined after "@function" ctx.isFunction = true; break; @@ -352,7 +352,7 @@ function processFile(props) { case 'event': case 'param': ctx[tag.type] = (ctx[tag.type] || []); - // the following is required, because in newer "dox" version "null" is not included in "types" anymore, but a seperate property + // the following is required, because in newer "dox" version "null" is not included in "types" anymore, but a separate property if (tag.nullable) { tag.types.push('null'); } diff --git a/package.json b/package.json index 464fc31e852..d520f041abe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongoose", "description": "Mongoose MongoDB ODM", - "version": "8.2.3", + "version": "8.2.4", "author": "Guillermo Rauch ", "keywords": [ "mongodb", @@ -28,8 +28,8 @@ "sift": "16.0.1" }, "devDependencies": { - "@babel/core": "7.24.0", - "@babel/preset-env": "7.24.0", + "@babel/core": "7.24.3", + "@babel/preset-env": "7.24.3", "@typescript-eslint/eslint-plugin": "^6.2.1", "@typescript-eslint/parser": "^6.2.1", "acquit": "1.3.0", @@ -46,7 +46,7 @@ "dotenv": "16.4.5", "dox": "1.0.0", "eslint": "8.57.0", - "eslint-plugin-markdown": "^3.0.1", + "eslint-plugin-markdown": "^4.0.1", "eslint-plugin-mocha-no-only": "1.1.1", "express": "^4.18.1", "fs-extra": "~11.2.0", @@ -56,7 +56,7 @@ "markdownlint-cli2": "^0.12.1", "marked": "4.3.0", "mkdirp": "^3.0.1", - "mocha": "10.3.0", + "mocha": "10.4.0", "moment": "2.x", "mongodb-memory-server": "8.15.1", "ncp": "^2.0.0", @@ -65,10 +65,10 @@ "q": "1.5.1", "sinon": "17.0.1", "stream-browserify": "3.0.0", - "tsd": "0.30.7", - "typescript": "5.3.3", + "tsd": "0.31.0", + "typescript": "5.4.3", "uuid": "9.0.1", - "webpack": "5.90.3" + "webpack": "5.91.0" }, "directories": { "lib": "./lib/mongoose" diff --git a/test/document.test.js b/test/document.test.js index f5d1a0b1fc6..8e0868dffbb 100644 --- a/test/document.test.js +++ b/test/document.test.js @@ -805,7 +805,7 @@ describe('document', function() { assert.deepStrictEqual(myModel.toObject().foo, {}); }); - it('should propogate toObject to implicitly created schemas (gh-13599) (gh-13325)', async function() { + it('should propagate toObject to implicitly created schemas (gh-13599) (gh-13325)', async function() { const transformCalls = []; const userSchema = Schema({ firstName: String, @@ -1017,7 +1017,7 @@ describe('document', function() { assert.equal(foundAlicJson.friends, undefined); assert.equal(foundAlicJson.name, 'Alic'); }); - it('should propogate toJSON to implicitly created schemas (gh-13599) (gh-13325)', async function() { + it('should propagate toJSON to implicitly created schemas (gh-13599) (gh-13325)', async function() { const transformCalls = []; const userSchema = Schema({ firstName: String, diff --git a/types/index.d.ts b/types/index.d.ts index 810fdb81949..f6835f6b329 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -280,7 +280,7 @@ declare module 'mongoose' { * * @remarks Search indexes are only supported when used against a 7.0+ Mongo Atlas cluster. */ - searchIndex(description: mongodb.SearchIndexDescription): this; + searchIndex(description: SearchIndexDescription): this; /** * Returns a list of indexes that this schema declares, via `schema.index()` diff --git a/types/indexes.d.ts b/types/indexes.d.ts index 3c5172352aa..f0891f081eb 100644 --- a/types/indexes.d.ts +++ b/types/indexes.d.ts @@ -86,4 +86,6 @@ declare module 'mongoose' { expires?: number | string; weights?: Record; } + + type SearchIndexDescription = mongodb.SearchIndexDescription; } diff --git a/types/models.d.ts b/types/models.d.ts index 7291e5ca79f..a56f1ee92e4 100644 --- a/types/models.d.ts +++ b/types/models.d.ts @@ -327,7 +327,7 @@ declare module 'mongoose' { * Create an [Atlas search index](https://www.mongodb.com/docs/atlas/atlas-search/create-index/). * This function only works when connected to MongoDB Atlas. */ - createSearchIndex(description: mongodb.SearchIndexDescription): Promise; + createSearchIndex(description: SearchIndexDescription): Promise; /** Connection the model uses. */ db: Connection; diff --git a/types/query.d.ts b/types/query.d.ts index ba719ef0242..32a502ed5a0 100644 --- a/types/query.d.ts +++ b/types/query.d.ts @@ -493,7 +493,7 @@ declare module 'mongoose' { get(path: string): any; /** Returns the current query filter (also known as conditions) as a POJO. */ - getFilter(): FilterQuery; + getFilter(): FilterQuery; /** Gets query options. */ getOptions(): QueryOptions; @@ -502,7 +502,7 @@ declare module 'mongoose' { getPopulatedPaths(): Array; /** Returns the current query filter. Equivalent to `getFilter()`. */ - getQuery(): FilterQuery; + getQuery(): FilterQuery; /** Returns the current update operations as a JSON object. */ getUpdate(): UpdateQuery | UpdateWithAggregationPipeline | null; diff --git a/types/schemaoptions.d.ts b/types/schemaoptions.d.ts index 32a9e909e38..31795187cf0 100644 --- a/types/schemaoptions.d.ts +++ b/types/schemaoptions.d.ts @@ -234,7 +234,7 @@ declare module 'mongoose' { query?: IfEquals< QueryHelpers, {}, - Record>(this: T, ...args: any) => T>, + Record>(this: T, ...args: any) => T>, QueryHelpers >