Skip to content

Commit

Permalink
deps(mongoose): upgrade to 8.0.0
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
mongoose 8.0.0 is now the version in use
  • Loading branch information
hasezoey committed Nov 3, 2023
1 parent e352ebf commit fc16e81
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/guides/error-warning-details.md
Expand Up @@ -7,7 +7,7 @@ title: 'Error & Warning Details'

### Mongoose Version [E001]

Error: `Please use mongoose 7.6.3 or higher (Current mongoose: x.x.x) [E001]`
Error: `Please use mongoose 8.0.0 or higher (Current mongoose: x.x.x) [E001]`

Error Class: `Error`

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/migration/migrate-12.md
Expand Up @@ -11,7 +11,7 @@ This Guide is written for migration from version `11.7.0` to `12.0.0`, for versi

## Requirements changed

<!-- - Mongoose `8.0.0` or higher is now required -->
- Mongoose `8.0.0` or higher is now required
- Typescript `5.2` or higher is now required to be used
- NodeJS 16 is now the lowest supported nodejs version

Expand Down
1 change: 1 addition & 0 deletions docs/guides/mongoose-compatibility.md
Expand Up @@ -9,6 +9,7 @@ If no upper mongoose version is defined and a newer typegoose version exists wit

| Typegoose Version | Mongoose Version |
| ----------------- | ---------------- |
| 12.0.x | ~8.0.0 |
| 11.7.x | ~7.6.3 |
| 11.6.x | ~7.6.1 |
| 11.5.x | ~7.5.0 |
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/quick-start-guide.md
Expand Up @@ -108,7 +108,7 @@ Like `public: string[]` is in reflection only `Array`.

- TypeScript version `^5.2` (since 10.0) is recommended, though older ones may also work
- NodeJS `>=16.20.1` (and `@types/node@16`)
- Mongoose `~7.6.3`
- Mongoose `~8.0.0`
- A IDE that supports TypeScript linting is recommended to be used (VSCode is recommended)
- This Guide expects you to know how Mongoose (or at least its models) works
- `experimentalDecorators` and `emitDecoratorMetadata` must be enabled in `tsconfig.json`
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -36,7 +36,7 @@
],
"license": "MIT",
"peerDependencies": {
"mongoose": "~7.6.3"
"mongoose": "~8.0.0"
},
"devDependencies": {
"@commitlint/cli": "^17.7.2",
Expand Down Expand Up @@ -66,7 +66,7 @@
"jest-runner-tsd": "^5.0.0",
"lint-staged": "^14.0.1",
"mongodb-memory-server": "^9.0.1",
"mongoose": "~7.6.3",
"mongoose": "~8.0.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"semantic-release": "^19.0.5",
Expand Down
4 changes: 3 additions & 1 deletion src/internal/utils.ts
Expand Up @@ -91,7 +91,9 @@ export function isAnRefType(Type: any): boolean {
export function isObject(Type: any, once: boolean = false): boolean {
if (typeof Type?.name === 'string') {
let prototype = Type.prototype;
let name = Type.name;
// schemaName is "Mixed", whereas name for ".Types.Mixed" is since mongoose 8.0 "SchemaMixed"
// so use "schemaName" if it exists and use ".name" as a fallback
let name = Type?.schemaName ?? Type.name;
while (name) {
if (name === 'Object' || name === 'Mixed') {
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/typegoose.ts
Expand Up @@ -19,8 +19,8 @@ import {
if (typeof process !== 'undefined' && !isNullOrUndefined(process?.version) && !isNullOrUndefined(mongoose?.version)) {
// for usage on client side
/* istanbul ignore next */
if (semver.lt(mongoose?.version, '7.6.3')) {
throw new Error(`Please use mongoose 7.6.3 or higher (Current mongoose: ${mongoose.version}) [E001]`);
if (semver.lt(mongoose?.version, '8.0.0')) {
throw new Error(`Please use mongoose 8.0.0 or higher (Current mongoose: ${mongoose.version}) [E001]`);
}

/* istanbul ignore next */
Expand Down
28 changes: 21 additions & 7 deletions yarn.lock
Expand Up @@ -2061,6 +2061,11 @@ bson@^5.5.0:
resolved "https://registry.yarnpkg.com/bson/-/bson-5.5.0.tgz#a419cc69f368d2def3b8b22ea03ed1c9be40e53f"
integrity sha512-B+QB4YmDx9RStKv8LLSl/aVIEV3nYJc3cJNNTK2Cd1TL+7P+cNpw9mAPeCgc5K+j01Dv6sxUzcITXDx7ZU3F0w==

bson@^6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/bson/-/bson-6.2.0.tgz#4b6acafc266ba18eeee111373c2699304a9ba0a3"
integrity sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==

buffer-crc32@~0.2.3:
version "0.2.13"
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
Expand Down Expand Up @@ -4932,7 +4937,16 @@ mongodb-memory-server@^9.0.1:
mongodb-memory-server-core "9.0.1"
tslib "^2.6.2"

mongodb@5.9.0, mongodb@^5.9.0:
mongodb@6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-6.2.0.tgz#2c9dcb3eeaf528ed850e94b3df392de6c6b0d7ab"
integrity sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==
dependencies:
"@mongodb-js/saslprep" "^1.1.0"
bson "^6.2.0"
mongodb-connection-string-url "^2.6.0"

mongodb@^5.9.0:
version "5.9.0"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-5.9.0.tgz#5a22065fa8cfaf1d58bf2e3c451cd2c4bfa983a2"
integrity sha512-g+GCMHN1CoRUA+wb1Agv0TI4YTSiWr42B5ulkiAfLLHitGK1R+PkSAf3Lr5rPZwi/3F04LiaZEW0Kxro9Fi2TA==
Expand All @@ -4943,14 +4957,14 @@ mongodb@5.9.0, mongodb@^5.9.0:
optionalDependencies:
"@mongodb-js/saslprep" "^1.1.0"

mongoose@~7.6.3:
version "7.6.3"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-7.6.3.tgz#b06507dd164ad4426013eeb266d54aa1e5178092"
integrity sha512-moYP2qWCOdWRDeBxqB/zYwQmQnTBsF5DoolX5uPyI218BkiA1ujGY27P0NTd4oWIX+LLkZPw0LDzlc/7oh1plg==
mongoose@~8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-8.0.0.tgz#f14175eebfaf5256855d7cbd58bf862819b3fd12"
integrity sha512-PzwkLgm1Jhj0NQdgGfnFsu0QP9V1sBFgbavEgh/IPAUzKAagzvEhuaBuAQOQGjczVWnpIU9tBqyd02cOTgsPlA==
dependencies:
bson "^5.5.0"
bson "^6.2.0"
kareem "2.5.1"
mongodb "5.9.0"
mongodb "6.2.0"
mpath "0.9.0"
mquery "5.0.0"
ms "2.1.3"
Expand Down

0 comments on commit fc16e81

Please sign in to comment.