Skip to content

Commit

Permalink
Merge branch 'master' into 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Apr 2, 2024
2 parents 663688f + 3aba5bf commit 52d1486
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/tidelift-alignment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 6 additions & 8 deletions docs/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -539,23 +538,22 @@ 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.
}
});

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
Expand Down
4 changes: 2 additions & 2 deletions docs/source/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
}
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
"version": "8.2.3",
"version": "8.2.4",
"author": "Guillermo Rauch <guillermo@learnboost.com>",
"keywords": [
"mongodb",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()`
Expand Down
2 changes: 2 additions & 0 deletions types/indexes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ declare module 'mongoose' {
expires?: number | string;
weights?: Record<string, number>;
}

type SearchIndexDescription = mongodb.SearchIndexDescription;
}
2 changes: 1 addition & 1 deletion types/models.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
createSearchIndex(description: SearchIndexDescription): Promise<string>;

/** Connection the model uses. */
db: Connection;
Expand Down
4 changes: 2 additions & 2 deletions types/query.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DocType>;
getFilter(): FilterQuery<RawDocType>;

/** Gets query options. */
getOptions(): QueryOptions<DocType>;
Expand All @@ -502,7 +502,7 @@ declare module 'mongoose' {
getPopulatedPaths(): Array<string>;

/** Returns the current query filter. Equivalent to `getFilter()`. */
getQuery(): FilterQuery<DocType>;
getQuery(): FilterQuery<RawDocType>;

/** Returns the current update operations as a JSON object. */
getUpdate(): UpdateQuery<DocType> | UpdateWithAggregationPipeline | null;
Expand Down
2 changes: 1 addition & 1 deletion types/schemaoptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ declare module 'mongoose' {
query?: IfEquals<
QueryHelpers,
{},
Record<any, <T extends QueryWithHelpers<unknown, THydratedDocumentType>>(this: T, ...args: any) => T>,
Record<any, <T extends QueryWithHelpers<unknown, THydratedDocumentType, QueryHelpers, DocType>>(this: T, ...args: any) => T>,
QueryHelpers
>

Expand Down

0 comments on commit 52d1486

Please sign in to comment.