mongoose 8.2.2 → 8.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.umd.js +1 -1
- package/lib/schema.js +10 -2
- package/package.json +3 -4
- package/types/index.d.ts +7 -0
- package/types/query.d.ts +17 -5
- package/types/schemaoptions.d.ts +5 -0
package/lib/schema.js
CHANGED
|
@@ -1220,10 +1220,18 @@ function _getPath(schema, path, cleanPath) {
|
|
|
1220
1220
|
return schema.paths[path];
|
|
1221
1221
|
}
|
|
1222
1222
|
if (schema.subpaths.hasOwnProperty(cleanPath)) {
|
|
1223
|
-
|
|
1223
|
+
const subpath = schema.subpaths[cleanPath];
|
|
1224
|
+
if (subpath === 'nested') {
|
|
1225
|
+
return undefined;
|
|
1226
|
+
}
|
|
1227
|
+
return subpath;
|
|
1224
1228
|
}
|
|
1225
1229
|
if (schema.singleNestedPaths.hasOwnProperty(cleanPath) && typeof schema.singleNestedPaths[cleanPath] === 'object') {
|
|
1226
|
-
|
|
1230
|
+
const singleNestedPath = schema.singleNestedPaths[cleanPath];
|
|
1231
|
+
if (singleNestedPath === 'nested') {
|
|
1232
|
+
return undefined;
|
|
1233
|
+
}
|
|
1234
|
+
return singleNestedPath;
|
|
1227
1235
|
}
|
|
1228
1236
|
|
|
1229
1237
|
return null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "8.2.
|
|
4
|
+
"version": "8.2.3",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -86,14 +86,13 @@
|
|
|
86
86
|
"docs:checkout:5x": "git checkout 5.x",
|
|
87
87
|
"docs:checkout:6x": "git checkout 6.x",
|
|
88
88
|
"docs:generate": "node ./scripts/website.js",
|
|
89
|
-
"docs:generate:search": "node ./scripts/generateSearch.js",
|
|
90
89
|
"docs:generate:sponsorData": "node ./scripts/loadSponsorData.js",
|
|
91
90
|
"docs:merge:stable": "git merge master",
|
|
92
91
|
"docs:merge:5x": "git merge 5.x",
|
|
93
92
|
"docs:merge:6x": "git merge 6.x",
|
|
94
|
-
"docs:test": "npm run docs:generate
|
|
93
|
+
"docs:test": "npm run docs:generate",
|
|
95
94
|
"docs:view": "node ./scripts/static.js",
|
|
96
|
-
"docs:prepare:publish:stable": "npm run docs:checkout:gh-pages && npm run docs:merge:stable && npm run docs:generate
|
|
95
|
+
"docs:prepare:publish:stable": "npm run docs:checkout:gh-pages && npm run docs:merge:stable && npm run docs:generate",
|
|
97
96
|
"docs:prepare:publish:5x": "npm run docs:checkout:5x && npm run docs:merge:5x && npm run docs:clean:stable && npm run docs:generate && npm run docs:copy:tmp && npm run docs:checkout:gh-pages && npm run docs:copy:tmp:5x",
|
|
98
97
|
"docs:prepare:publish:6x": "npm run docs:checkout:6x && npm run docs:merge:6x && npm run docs:clean:stable && env DOCS_DEPLOY=true npm run docs:generate && npm run docs:move:6x:tmp && npm run docs:checkout:gh-pages && npm run docs:copy:tmp:6x",
|
|
99
98
|
"docs:prepare:publish:7x": "env DOCS_DEPLOY=true npm run docs:generate && npm run docs:checkout:gh-pages && rimraf ./docs/7.x && mv ./tmp ./docs/7.x",
|
package/types/index.d.ts
CHANGED
|
@@ -274,6 +274,13 @@ declare module 'mongoose' {
|
|
|
274
274
|
/** Defines an index (most likely compound) for this schema. */
|
|
275
275
|
index(fields: IndexDefinition, options?: IndexOptions): this;
|
|
276
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Define a search index for this schema.
|
|
279
|
+
*
|
|
280
|
+
* @remarks Search indexes are only supported when used against a 7.0+ Mongo Atlas cluster.
|
|
281
|
+
*/
|
|
282
|
+
searchIndex(description: mongodb.SearchIndexDescription): this;
|
|
283
|
+
|
|
277
284
|
/**
|
|
278
285
|
* Returns a list of indexes that this schema declares, via `schema.index()`
|
|
279
286
|
* or by `index: true` in a path's options.
|
package/types/query.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
declare module 'mongoose' {
|
|
2
2
|
import mongodb = require('mongodb');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
type
|
|
4
|
+
type StringQueryTypeCasting = string | RegExp;
|
|
5
|
+
type ObjectIdQueryTypeCasting = Types.ObjectId | string;
|
|
6
|
+
type UUIDQueryTypeCasting = Types.UUID | string;
|
|
7
|
+
|
|
8
|
+
type QueryTypeCasting<T> = T extends string
|
|
9
|
+
? StringQueryTypeCasting
|
|
10
|
+
: T extends Types.ObjectId
|
|
11
|
+
? ObjectIdQueryTypeCasting
|
|
12
|
+
: T extends Types.UUID
|
|
13
|
+
? UUIDQueryTypeCasting
|
|
14
|
+
: T | any;
|
|
15
|
+
|
|
16
|
+
export type ApplyBasicQueryCasting<T> = T | T[] | (T extends (infer U)[] ? QueryTypeCasting<U> : T);
|
|
17
|
+
export type Condition<T> = ApplyBasicQueryCasting<QueryTypeCasting<T>> | QuerySelector<ApplyBasicQueryCasting<QueryTypeCasting<T>>>;
|
|
6
18
|
|
|
7
19
|
type _FilterQuery<T> = {
|
|
8
20
|
[P in keyof T]?: Condition<T[P]>;
|
|
@@ -385,7 +397,7 @@ declare module 'mongoose' {
|
|
|
385
397
|
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find'>;
|
|
386
398
|
find(
|
|
387
399
|
filter: FilterQuery<RawDocType>
|
|
388
|
-
): QueryWithHelpers<Array<
|
|
400
|
+
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find'>;
|
|
389
401
|
find(): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find'>;
|
|
390
402
|
|
|
391
403
|
/** Declares the query a findOne operation. When executed, returns the first found document. */
|
|
@@ -481,7 +493,7 @@ declare module 'mongoose' {
|
|
|
481
493
|
get(path: string): any;
|
|
482
494
|
|
|
483
495
|
/** Returns the current query filter (also known as conditions) as a POJO. */
|
|
484
|
-
getFilter(): FilterQuery<
|
|
496
|
+
getFilter(): FilterQuery<DocType>;
|
|
485
497
|
|
|
486
498
|
/** Gets query options. */
|
|
487
499
|
getOptions(): QueryOptions<DocType>;
|
|
@@ -490,7 +502,7 @@ declare module 'mongoose' {
|
|
|
490
502
|
getPopulatedPaths(): Array<string>;
|
|
491
503
|
|
|
492
504
|
/** Returns the current query filter. Equivalent to `getFilter()`. */
|
|
493
|
-
getQuery(): FilterQuery<
|
|
505
|
+
getQuery(): FilterQuery<DocType>;
|
|
494
506
|
|
|
495
507
|
/** Returns the current update operations as a JSON object. */
|
|
496
508
|
getUpdate(): UpdateQuery<DocType> | UpdateWithAggregationPipeline | null;
|
package/types/schemaoptions.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ declare module 'mongoose' {
|
|
|
24
24
|
* automatic index builds, you can set autoIndex to false.
|
|
25
25
|
*/
|
|
26
26
|
autoIndex?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Similar to autoIndex, except for automatically creates any Atlas search indexes defined in your
|
|
29
|
+
* schema. Unlike autoIndex, this option defaults to false.
|
|
30
|
+
*/
|
|
31
|
+
autoSearchIndex?: boolean;
|
|
27
32
|
/**
|
|
28
33
|
* If set to `true`, Mongoose will call Model.createCollection() to create the underlying collection
|
|
29
34
|
* in MongoDB if autoCreate is set to true. Calling createCollection() sets the collection's default
|