Skip to content

Commit

Permalink
Merge branch 'master' into vkarpov15/gh-4292
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 16, 2023
2 parents 73a524b + eeefdd2 commit 7ae5f46
Show file tree
Hide file tree
Showing 86 changed files with 1,115 additions and 616 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module.exports = {
'test/files/*',
'benchmarks',
'*.min.js',
'**/docs/js/native.js'
'**/docs/js/native.js',
'!.*',
'node_modules'
],
overrides: [
{
Expand Down
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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,31 @@ permissions:
contents: read

jobs:
lint-documentation:
runs-on: ubuntu-latest
name: Lint Markdown files
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 16

- run: npm install

- name: Lint MD-Files # run markdownlint
run: npm run lint-md

# enable when "eslint-markdown" can be used without errors
# - name: Lint JS-Files # run eslint to lint the code-blocks themself
# run: npm run lint-js

test-documentation:
runs-on: ubuntu-20.04
name: Test Generating Docs
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- 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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
MONGOMS_VERSION: ${{ matrix.mongodb }}
MONGOMS_PREFER_GLOBAL_PATH: 1
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
MONGOMS_VERSION: 6.0.4
MONGOMS_PREFER_GLOBAL_PATH: 1
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
Expand All @@ -118,7 +118,7 @@ jobs:
runs-on: ubuntu-latest
name: Replica Set tests
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
Expand All @@ -135,6 +135,6 @@ jobs:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Dependency review
uses: actions/dependency-review-action@v3
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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
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 @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
name: Lint TS-Files
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
Expand All @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
name: Test Typescript Types
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
Expand Down
69 changes: 69 additions & 0 deletions .markdownlint-cli2.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
'use strict';
// this file is named ".cjs" instead of ".js" because markdownlint-cli2 only looks for ".cjs" or ".mjs"

// use aliases instead of "MD000" naming

module.exports = {
ignores: [
// the following are ignored because they are just redirects
'History.md',
'SECURITY.md',
'migrating_to_5.md', // this does not affect "docs/migrating_to_5.md"

// ignored for now, but should be changes later
'.github/PULL_REQUEST_TEMPLATE.md',

// ignore changelog because it uses different heading style than other documents and older versions use different formatting
'CHANGELOG.md',

// exclude node_modules because it isnt excluded by default
'node_modules'
]
};

module.exports.config = {
// disable default rules
default: false,

// alt-text for images
accessibility: true,
// consistent blank lines
blank_lines: true,
// consistent unordered lists
bullet: { style: 'asterisk' },
// consistent and read-able code
code: true,
// consistent emphasis characters
emphasis: { style: 'asterisk' },
// ensure consistent header usage
headers: { style: 'atx' },
// ensure consistent "hr" usage
hr: { style: '---' },
// disable disalloing html tags, because
// mongoose currently uses html tags directly for heading ID's and style
html: false,
// consistent indentation
indentation: true,
// consistent links and good links
links: true,
// enabled by "links"
// mongoose currently does not wrap plain links in "<>"
'no-bare-urls': false,
// consistent ordered lists
ol: true,
// consistent whitespace usage
whitespace: true

// atx: undefined, // covered by "headers"
// atx_closed: undefined, // covered by "headers"
// blockquote: true, // covered by "whitespace"
// hard_tab: undefined, // covered by "whitespace"
// headings: undefined, // covered by "headers"
// images: true, // covered by "accessibility" and "links"
// language: undefined, // covered by "code"
// line_length: undefined, // mongoose currently uses a mix of max-line-length and relying on editor auto-wrap
// spaces: undefined, // covered by "atx", "atx_closed", "headers"
// spelling: undefined, // mongoose currently only uses short-form language specifiers and so does not need this
// ul: undefined, // covered by "whitespace" and "bullet"
// url: undefined, // covered by "links"
};
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
7.3.4 / 2023-07-12
==================
* chore: release 7.4.4 to overwrite accidental publish of 5.13.20 to latest tag

6.11.3 / 2023-07-11
===================
* fix: avoid prototype pollution on init
* fix(schema): correctly handle uuids with populate() #13317 #13595

7.3.3 / 2023-07-10
==================
* fix: avoid prototype pollution on init
* fix(document): clean up all array subdocument modified paths on save() #13589 #13582
* types: avoid unnecessary MergeType<> if TOverrides not set, clean up statics and insertMany() type issues #13577 #13529

7.3.2 / 2023-07-06
==================
* fix(model): avoid TypeError if insertMany() fails with error that does not have writeErrors property #13579 #13531
* fix(query): convert findOneAndUpdate to findOneAndReplace when overwrite set for backwards compat with Mongoose 6 #13572 #13550
* fix(query): throw readable error when executing a Query instance without an associated model #13571 #13570
* types: support mongoose.Schema.ObjectId as alias for mongoose.Schema.Types.ObjectId #13543 #13534
* docs(connections): clarify that socketTimeoutMS now defaults to 0 #13576 #13537
* docs(migrating_to_7): add mapReduce() removal to migration guide #13568 #13548
* docs(schemas): fix typo in schemas.md #13540 [Metehan-Altuntekin](https://github.com/Metehan-Altuntekin)

7.3.1 / 2023-06-21
==================
* fix(query): respect query-level strict option on findOneAndReplace() #13516 #13507
* docs(connections): expand docs on serverSelectionTimeoutMS #13533 #12967
* docs: add example of accessing save options in pre save #13498
* docs(connections+faq): add info on localhost vs 127.0.0.1
* docs(SchemaType): validate members are validator & message (not msg) #13521 [lorand-horvath](https://github.com/lorand-horvath)

7.3.0 / 2023-06-14
==================
* feat: upgrade mongodb -> 5.6.0 #13455 [lorand-horvath](https://github.com/lorand-horvath)
Expand Down
96 changes: 48 additions & 48 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
## Contributing to Mongoose
# Contributing to Mongoose

If you have a question about Mongoose (not a bug report) please post it to either [StackOverflow](http://stackoverflow.com/questions/tagged/mongoose), or on [Gitter](https://gitter.im/Automattic/mongoose?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

### Reporting bugs
## Reporting bugs

- Before opening a new issue, look for existing [issues](https://github.com/Automattic/mongoose/issues) to avoid duplication. If the issue does not yet exist, [create one](https://github.com/Automattic/mongoose/issues/new).
- Please post any relevant code samples, preferably a standalone script that
* Before opening a new issue, look for existing [issues](https://github.com/Automattic/mongoose/issues) to avoid duplication. If the issue does not yet exist, [create one](https://github.com/Automattic/mongoose/issues/new).
* Please post any relevant code samples, preferably a standalone script that
reproduces your issue. Do **not** describe your issue in prose. **Show your code.**
- If the bug involves an error, please post the stack trace.
- Please post the version of Mongoose and MongoDB that you're using.
- Please write bug reports in JavaScript (ES5, ES6, etc) that runs in Node.js, **not** CoffeeScript, TypeScript, JSX, etc.

### Requesting new features

- Before opening a new issue, look for existing [issues](https://github.com/learnboost/mongoose/issues) to avoid duplication. If the issue does not yet exist, [create one](https://github.com/learnboost/mongoose/issues/new).
- Please describe a use case for it
- Please include test cases if possible

### Fixing bugs / Adding features

- Before starting to write code, look for existing [issues](https://github.com/learnboost/mongoose/issues). That way you avoid working on something that might not be of interest or that has been addressed already in a different branch. You can create a new issue [here](https://github.com/learnboost/mongoose/issues/new).
- _The source of this project is written in JavaScript, not CoffeeScript or TypeScript. Please write your bug reports in JavaScript that can run in vanilla Node.js_.
- Fork the [repo](https://github.com/Automattic/mongoose) _or_ for small documentation changes, navigate to the source on github and click the [Edit](https://github.com/blog/844-forking-with-the-edit-button) button.
- Follow the general coding style of the rest of the project:
- 2 space tabs
- no trailing whitespace
- inline documentation for new methods, class members, etc.
- 1 space between conditionals, no space before function parenthesis
- `if (..) {`
- `for (..) {`
- `while (..) {`
- `function(err) {`
- Write tests and make sure they pass (tests are in the [test](https://github.com/Automattic/mongoose/tree/master/test) directory).
- Write typings-tests if you modify the typescript-typings. (tests are in the [test/types](https://github.com/Automattic/mongoose/tree/master/test/types) directory).

### Running the tests

- Open a terminal and navigate to the root of the project
- execute `npm install` to install the necessary dependencies
- execute `npm run mongo` to start a MongoDB instance on port 27017. This step is optional, if you have already a database running on port 27017. To spin up a specific mongo version, you can do it by executing `npm run mongo -- {version}`. E.g. you want to spin up a mongo 4.2.2 server, you execute `npm run mongo -- 4.2.2`
- execute `npm test` to run the tests (we're using [mocha](http://mochajs.org/))
- or to execute a single test `npm test -- -g 'some regexp that matches the test description'`
- any mocha flags can be specified with `-- <mocha flags here>`
- For example, you can use `npm test -- -R spec` to use the spec reporter, rather than the dot reporter (by default, the test output looks like a bunch of dots)
- execute `npm run test-tsd` to run the typescript tests
- execute `npm run ts-benchmark` to run the typescript benchmark "performance test" for a single time.
- execute `npm run ts-benchmark-watch` to run the typescript benchmark "performance test" while watching changes on types folder. Note: Make sure to commit all changes before executing this command.

### Documentation
* If the bug involves an error, please post the stack trace.
* Please post the version of Mongoose and MongoDB that you're using.
* Please write bug reports in JavaScript (ES5, ES6, etc) that runs in Node.js, **not** CoffeeScript, TypeScript, JSX, etc.

## Requesting new features

* Before opening a new issue, look for existing [issues](https://github.com/learnboost/mongoose/issues) to avoid duplication. If the issue does not yet exist, [create one](https://github.com/learnboost/mongoose/issues/new).
* Please describe a use case for it
* Please include test cases if possible

## Fixing bugs / Adding features

* Before starting to write code, look for existing [issues](https://github.com/learnboost/mongoose/issues). That way you avoid working on something that might not be of interest or that has been addressed already in a different branch. You can create a new issue [here](https://github.com/learnboost/mongoose/issues/new).
* *The source of this project is written in JavaScript, not CoffeeScript or TypeScript. Please write your bug reports in JavaScript that can run in vanilla Node.js*.
* Fork the [repo](https://github.com/Automattic/mongoose) *or* for small documentation changes, navigate to the source on github and click the [Edit](https://github.com/blog/844-forking-with-the-edit-button) button.
* Follow the general coding style of the rest of the project:
* 2 space tabs
* no trailing whitespace
* inline documentation for new methods, class members, etc.
* 1 space between conditionals, no space before function parenthesis
* `if (..) {`
* `for (..) {`
* `while (..) {`
* `function(err) {`
* Write tests and make sure they pass (tests are in the [test](https://github.com/Automattic/mongoose/tree/master/test) directory).
* Write typings-tests if you modify the typescript-typings. (tests are in the [test/types](https://github.com/Automattic/mongoose/tree/master/test/types) directory).

## Running the tests

* Open a terminal and navigate to the root of the project
* execute `npm install` to install the necessary dependencies
* execute `npm run mongo` to start a MongoDB instance on port 27017. This step is optional, if you have already a database running on port 27017. To spin up a specific mongo version, you can do it by executing `npm run mongo -- {version}`. E.g. you want to spin up a mongo 4.2.2 server, you execute `npm run mongo -- 4.2.2`
* execute `npm test` to run the tests (we're using [mocha](http://mochajs.org/))
* or to execute a single test `npm test -- -g 'some regexp that matches the test description'`
* any mocha flags can be specified with `-- <mocha flags here>`
* For example, you can use `npm test -- -R spec` to use the spec reporter, rather than the dot reporter (by default, the test output looks like a bunch of dots)
* execute `npm run test-tsd` to run the typescript tests
* execute `npm run ts-benchmark` to run the typescript benchmark "performance test" for a single time.
* execute `npm run ts-benchmark-watch` to run the typescript benchmark "performance test" while watching changes on types folder. Note: Make sure to commit all changes before executing this command.

## Documentation

To contribute to the [API documentation](http://mongoosejs.com/docs/api/mongoose.html) just make your changes to the inline documentation of the appropriate [source code](https://github.com/Automattic/mongoose/tree/master/lib) in the master branch and submit a [pull request](https://help.github.com/articles/using-pull-requests/). You might also use the github [Edit](https://github.com/blog/844-forking-with-the-edit-button) button.

Expand All @@ -60,13 +60,13 @@ If you'd like to preview your documentation changes, first commit your changes t

Visit `http://127.0.0.1:8089` and you should see the docs with your local changes. Make sure you `npm run docs:clean` before committing, because automated generated files to `docs/*` should **not** be in PRs.

#### Documentation Style Guidelines
### Documentation Style Guidelines

There are some guidelines to keep the style for the documentation consistent:

- All links that refer to some other file in the mongoose documentation needs to be relative without a prefix unless required (use `guide.html` over `./guide.html` or `/docs/guide.html`)
* All links that refer to some other file in the mongoose documentation needs to be relative without a prefix unless required (use `guide.html` over `./guide.html` or `/docs/guide.html`)

### Plugins website
## Plugins website

The [plugins](http://plugins.mongoosejs.io/) site is also an [open source project](https://github.com/vkarpov15/mongooseplugins) that you can get involved with. Feel free to fork and improve it as well!

Expand Down
Loading

0 comments on commit 7ae5f46

Please sign in to comment.