Skip to content

Commit 42edf65

Browse files
authored
Merge branch 'master' into vkarpov15/Automatticgh-15779
2 parents 071e0b1 + 70466d0 commit 42edf65

File tree

8 files changed

+50
-36
lines changed

8 files changed

+50
-36
lines changed

docs/compatibility.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
}
1212
</style>
1313

14-
Mongoose relies on the [MongoDB Node.js Driver](http://mongodb.github.io/node-mongodb-native/) to talk to MongoDB.
15-
You can refer to [this table](https://www.mongodb.com/docs/drivers/node/current/compatibility/) for up-to-date information as to which version of the MongoDB driver supports which version of MongoDB.
14+
Mongoose relies on the [MongoDB Node.js Driver](https://www.mongodb.com/docs/drivers/node/current/) to communicate with MongoDB.
1615

17-
Below are the [semver](http://semver.org/) ranges representing which versions of mongoose are compatible with the listed versions of MongoDB server.
16+
You can refer to [this table](https://www.mongodb.com/docs/drivers/compatibility/?driver-language=javascript&javascript-driver-framework=nodejs) for up-to-date information as to which version of the MongoDB driver supports which version of the MongoDB server.
17+
18+
Below are the [SemVer](http://semver.org/) ranges representing which versions of mongoose are compatible with the listed versions of MongoDB server.
1819

1920
| MongoDB Server | Mongoose |
2021
| :------------: | :--------------------------------------------: |
21-
| `8.x` | `^8.7.0 | ^9.0.0` |
22+
| `8.x` | `^8.7.0 \| ^9.0.0` |
2223
| `7.x` | `^7.4.0 \| ^8.0.0 \| ^9.0.0` |
2324
| `6.x` | `^7.0.0 \| ^8.0.0 \| ^9.0.0` |
2425
| `5.x` | `^6.0.0 \| ^7.0.0 \| ^8.0.0` |
@@ -27,4 +28,4 @@ Below are the [semver](http://semver.org/) ranges representing which versions of
2728
| `4.0.x` | `^6.0.0 \| ^7.0.0 \| ^8.0.0 <8.16.0` |
2829
| `3.6.x` | `^6.0.0 \| ^7.0.0 \| ^8.0.0 <8.8.0` |
2930

30-
Mongoose `^6.5.0` also works with MongoDB server 7.x. But not all new MongoDB server 7.x features are supported by Mongoose 6.x.
31+
Mongoose `^6.5.0` also works with MongoDB server 7.x. But not all new MongoDB server 7.x features are supported by Mongoose 6.x. To verify that your version of Mongoose is compatible based on the table above, use the [online SemVer checker](https://jubianchi.github.io/semver-check/#/).

docs/source/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function processFile(props) {
269269
if ('constructor' in ctx && ctx.constructor === undefined) {
270270
ctx.constructorWasUndefined = true;
271271
}
272-
272+
if (!prop.tags) continue;
273273
for (const __tag of prop.tags) {
274274
// the following has been done, because otherwise no type could be applied for intellisense
275275
/** @type {TagObject} */

scripts/generateSearch.js

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,17 @@ function generateContents() {
6363
content.validateSync();
6464

6565
const $ = cheerio.load(text);
66-
6766
contents.push(content);
6867

69-
// Break up individual h3's into separate content for more fine grained search
68+
// Break up h3's into additional content entries
7069
$('h3').each((index, el) => {
7170
el = $(el);
7271
const title = el.text();
7372
const html = el.nextUntil('h3').html();
73+
74+
// *** FIXED: Skip empty HTML blocks ***
75+
if (!html || html.trim() === '') return;
76+
7477
const id = el.prop('id');
7578
const baseUrl = filename.replace('.md', '.html').replace(/^docs/, '');
7679
const content = new Content({
@@ -82,6 +85,7 @@ function generateContents() {
8285
content.validateSync();
8386
contents.push(content);
8487
});
88+
8589
} else if (file.guide) {
8690
let text = fs.readFileSync(filename, 'utf8');
8791
text = text.substring(text.indexOf('block content') + 'block content\n'.length);
@@ -96,14 +100,17 @@ function generateContents() {
96100
content.validateSync();
97101

98102
const $ = cheerio.load(text);
99-
100103
contents.push(content);
101104

102-
// Break up individual h3's into separate content for more fine grained search
105+
// Break up h3's into additional content entries
103106
$('h3').each((index, el) => {
104107
el = $(el);
105108
const title = el.text();
106109
const html = el.nextUntil('h3').html();
110+
111+
// *** FIXED: Skip empty HTML blocks ***
112+
if (!html || html.trim() === '') return;
113+
107114
const id = el.prop('id');
108115
const baseUrl = filename.replace('.pug', '.html').replace(/^docs/, '');
109116
const content = new Content({
@@ -137,56 +144,47 @@ async function generateSearch(config) {
137144

138145
const promises = [];
139146
let lastPrint = 0;
140-
141147
let doneCount = 0;
148+
142149
console.log('Search Content to save:', contents.length);
150+
143151
for (const content of contents) {
144-
if (version === '9.x') {
145-
let url = content.url.startsWith('/') ? content.url : `/${content.url}`;
146-
if (!url.startsWith('/docs')) {
147-
url = '/docs' + url;
148-
}
149-
content.url = url;
150-
} else {
151-
let url = content.url.startsWith('/') ? content.url : `/${content.url}`;
152-
if (!url.startsWith('/docs')) {
153-
url = '/docs' + url;
154-
}
155-
content.url = `/docs/${version}${url}`;
152+
let url = content.url.startsWith('/') ? content.url : `/${content.url}`;
153+
if (!url.startsWith('/docs')) {
154+
url = '/docs' + url;
156155
}
156+
content.url = version === '9.x' ? url : `/docs/${version}${url}`;
157+
157158
const promise = content.save().then(() => {
158159
doneCount += 1;
159160
const nowDate = Date.now();
160-
// only print every 2 seconds, or if it is the first or last element
161161
if (nowDate - lastPrint > 2000 || doneCount === contents.length || doneCount === 1) {
162162
lastPrint = nowDate;
163163
console.log(`${doneCount} / ${contents.length}`);
164164
}
165165
});
166+
166167
promises.push(promise);
167168
}
168169

169170
await Promise.allSettled(promises);
170171

171-
const results = await Content.
172-
find({ $text: { $search: 'validate' }, version }, { score: { $meta: 'textScore' } }).
173-
sort({ score: { $meta: 'textScore' } }).
174-
limit(10);
172+
const results = await Content
173+
.find({ $text: { $search: 'validate' }, version }, { score: { $meta: 'textScore' } })
174+
.sort({ score: { $meta: 'textScore' } })
175+
.limit(10);
175176

176177
console.log(results.map(res => res.url));
177178

178179
console.log(`Added ${contents.length} Search Content`);
179-
180-
// this likely should not be done as part of this script, but by the caller,
181-
// but this script is currently the only one that connects in the website generation.
182180
await mongoose.disconnect();
183181
}
184182

185183
function getConfig() {
186184
const config = require('../.config.js');
187185

188186
if (!config || !config.uri) {
189-
throw new Error('No Config or config.URI given, please create a .config.js file with those values in the root of the repository');
187+
throw new Error('No Config or config.uri given, please create a .config.js file with those values in the root of the repository');
190188
}
191189

192190
return config;
@@ -195,7 +193,6 @@ function getConfig() {
195193
module.exports.generateSearch = generateSearch;
196194
module.exports.getConfig = getConfig;
197195

198-
// only run the following code if this file is the main module / entry file
199196
if (isMain) {
200197
(async function main() {
201198
const config = getConfig();

test/types/connection.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,6 @@ async function gh15359() {
167167
{ model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } }
168168
], { ordered: false });
169169
expectType<number>(res3.insertedCount);
170+
expectError(res3.validationErrors);
170171
expectType<Error[] | undefined>(res3.mongoose?.validationErrors);
171172
}

test/types/document.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ function gh11085(): void {
166166

167167
const newUser = new UserModel();
168168

169-
let _id: number;
170-
expectError(_id = newUser._id);
171169
const _id2: Types.ObjectId = newUser._id;
172170
}
173171

test/types/queries.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,3 +851,17 @@ async function gh15779() {
851851
TestModel.findOne(query);
852852
TestModel.deleteMany(query);
853853
}
854+
855+
async function gh15786() {
856+
interface IDoc {
857+
nmae: string;
858+
}
859+
860+
interface DocStatics {
861+
m1(): void;
862+
m2(): void;
863+
}
864+
865+
const schema = new Schema<IDoc, Model<IDoc>, {}, {}, {}, DocStatics>({});
866+
schema.static({ m1() {} } as DocStatics);
867+
}

test/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ exports.clearTestData = async function clearTestData(db) {
1919
retries -= 1;
2020
try {
2121
await _inner();
22+
return;
2223
} catch (err) {
23-
if (err instanceof mongoose.mongo.MongoWriteConcernError && /operation was interrupted/.test(err.message)) {
24+
const retryable = err instanceof mongoose.mongo.MongoWriteConcernError && /operation was interrupted/.test(err.message);
25+
if (retryable && retries > 0) {
2426
console.log('DropDB operation interrupted, retrying'); // log that a error was thrown to know that it is going to re-try
2527
continue;
2628
}

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ declare module 'mongoose' {
623623

624624
/** Adds static "class" methods to Models compiled from this schema. */
625625
static<K extends keyof TStaticMethods>(name: K, fn: TStaticMethods[K]): this;
626+
static(obj: { [F in keyof TStaticMethods]: TStaticMethods[F] }): this;
626627
static(obj: { [F in keyof TStaticMethods]: TStaticMethods[F] } & { [name: string]: (this: TModelType, ...args: any[]) => any }): this;
627628
static(name: string, fn: (this: TModelType, ...args: any[]) => any): this;
628629

0 commit comments

Comments
 (0)