mongoose 6.2.8 → 6.2.11
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/.eslintrc.json +35 -26
- package/CHANGELOG.md +28 -0
- package/dist/browser.umd.js +38 -27
- package/lib/aggregate.js +57 -66
- package/lib/browser.js +4 -4
- package/lib/connection.js +21 -21
- package/lib/cursor/AggregationCursor.js +2 -2
- package/lib/cursor/QueryCursor.js +3 -3
- package/lib/document.js +65 -49
- package/lib/error/index.js +2 -2
- package/lib/helpers/indexes/applySchemaCollation.js +13 -0
- package/lib/helpers/indexes/isTextIndex.js +16 -0
- package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/lib/helpers/query/castUpdate.js +3 -1
- package/lib/helpers/update/applyTimestampsToChildren.js +2 -2
- package/lib/helpers/update/applyTimestampsToUpdate.js +0 -1
- package/lib/index.js +24 -26
- package/lib/model.js +144 -146
- package/lib/options/SchemaArrayOptions.js +2 -2
- package/lib/options/SchemaBufferOptions.js +1 -1
- package/lib/options/SchemaDateOptions.js +9 -2
- package/lib/options/SchemaDocumentArrayOptions.js +3 -3
- package/lib/options/SchemaMapOptions.js +2 -2
- package/lib/options/SchemaNumberOptions.js +3 -3
- package/lib/options/SchemaObjectIdOptions.js +2 -2
- package/lib/options/SchemaStringOptions.js +1 -1
- package/lib/options/SchemaSubdocumentOptions.js +2 -2
- package/lib/options/SchemaTypeOptions.js +3 -3
- package/lib/query.js +291 -248
- package/lib/schema/SubdocumentPath.js +4 -3
- package/lib/schema/array.js +2 -2
- package/lib/schema/boolean.js +4 -4
- package/lib/schema/buffer.js +3 -3
- package/lib/schema/date.js +7 -7
- package/lib/schema/decimal128.js +2 -2
- package/lib/schema/documentarray.js +3 -3
- package/lib/schema/mixed.js +2 -2
- package/lib/schema/number.js +6 -6
- package/lib/schema/objectid.js +4 -7
- package/lib/schema/string.js +38 -16
- package/lib/schema.js +30 -29
- package/lib/schematype.js +78 -69
- package/lib/types/ArraySubdocument.js +1 -1
- package/lib/types/DocumentArray/methods/index.js +2 -2
- package/lib/types/array/index.js +1 -1
- package/lib/types/array/methods/index.js +13 -13
- package/lib/types/buffer.js +1 -1
- package/lib/types/decimal128.js +1 -1
- package/lib/types/objectid.js +1 -1
- package/lib/types/subdocument.js +31 -2
- package/lib/virtualtype.js +3 -3
- package/package.json +18 -16
- package/tools/repl.js +8 -8
- package/tools/sharded.js +3 -3
- package/types/aggregate.d.ts +223 -0
- package/types/connection.d.ts +116 -116
- package/types/error.d.ts +2 -2
- package/types/index.d.ts +76 -213
- package/types/pipelinestage.d.ts +194 -194
- package/types/schemaoptions.d.ts +2 -2
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="./aggregate.d.ts" />
|
|
1
2
|
/// <reference path="./connection.d.ts" />
|
|
2
3
|
/// <reference path="./cursor.d.ts" />
|
|
3
4
|
/// <reference path="./document.d.ts" />
|
|
@@ -178,7 +179,7 @@ declare module 'mongoose' {
|
|
|
178
179
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
179
180
|
interface ClientSession extends mongodb.ClientSession { }
|
|
180
181
|
|
|
181
|
-
|
|
182
|
+
/*
|
|
182
183
|
* section collection.js
|
|
183
184
|
* http://mongoosejs.com/docs/api.html#collection-js
|
|
184
185
|
*/
|
|
@@ -231,7 +232,9 @@ declare module 'mongoose' {
|
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
type AnyKeys<T> = { [P in keyof T]?: T[P] | any };
|
|
234
|
-
interface AnyObject {
|
|
235
|
+
interface AnyObject {
|
|
236
|
+
[k: string]: any
|
|
237
|
+
}
|
|
235
238
|
|
|
236
239
|
type Require_id<T> = T extends { _id?: any } ? (T & { _id: T['_id'] }) : (T & { _id: Types.ObjectId });
|
|
237
240
|
|
|
@@ -246,7 +249,11 @@ declare module 'mongoose' {
|
|
|
246
249
|
|
|
247
250
|
interface ModifyResult<T> {
|
|
248
251
|
value: Require_id<T> | null;
|
|
249
|
-
|
|
252
|
+
/** see https://www.mongodb.com/docs/manual/reference/command/findAndModify/#lasterrorobject */
|
|
253
|
+
lastErrorObject?: {
|
|
254
|
+
updatedExisting?: boolean;
|
|
255
|
+
upserted?: mongodb.ObjectId;
|
|
256
|
+
};
|
|
250
257
|
ok: 0 | 1;
|
|
251
258
|
}
|
|
252
259
|
|
|
@@ -749,8 +756,6 @@ declare module 'mongoose' {
|
|
|
749
756
|
type SchemaPreOptions = { document?: boolean, query?: boolean };
|
|
750
757
|
type SchemaPostOptions = { document?: boolean, query?: boolean };
|
|
751
758
|
|
|
752
|
-
type ExtractVirtuals<M> = M extends Model<any, any, any, infer TVirtuals> ? TVirtuals : {};
|
|
753
|
-
|
|
754
759
|
type IndexDirection = 1 | -1 | '2d' | '2dsphere' | 'geoHaystack' | 'hashed' | 'text';
|
|
755
760
|
type IndexDefinition = Record<string, IndexDirection>;
|
|
756
761
|
|
|
@@ -906,23 +911,24 @@ declare module 'mongoose' {
|
|
|
906
911
|
type SchemaDefinitionWithBuiltInClass<T> = T extends number
|
|
907
912
|
? NumberSchemaDefinition
|
|
908
913
|
: T extends string
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
914
|
+
? StringSchemaDefinition
|
|
915
|
+
: T extends boolean
|
|
916
|
+
? BooleanSchemaDefinition
|
|
917
|
+
: T extends NativeDate
|
|
918
|
+
? DateSchemaDefinition
|
|
919
|
+
: (Function | string);
|
|
915
920
|
|
|
916
921
|
type SchemaDefinitionProperty<T = undefined> = SchemaDefinitionWithBuiltInClass<T> |
|
|
917
|
-
|
|
922
|
+
SchemaTypeOptions<T extends undefined ? any : T> |
|
|
918
923
|
typeof SchemaType |
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
typeof
|
|
924
|
+
Schema<any, any, any> |
|
|
925
|
+
Schema<any, any, any>[] |
|
|
926
|
+
SchemaTypeOptions<T extends undefined ? any : Unpacked<T>>[] |
|
|
927
|
+
Function[] |
|
|
928
|
+
SchemaDefinition<T> |
|
|
929
|
+
SchemaDefinition<Unpacked<T>>[] |
|
|
930
|
+
typeof Schema.Types.Mixed |
|
|
931
|
+
MixedSchemaTypeOptions;
|
|
926
932
|
|
|
927
933
|
type SchemaDefinition<T = undefined> = T extends undefined
|
|
928
934
|
? { [path: string]: SchemaDefinitionProperty; }
|
|
@@ -937,22 +943,26 @@ declare module 'mongoose' {
|
|
|
937
943
|
|
|
938
944
|
type ExtractMongooseArray<T> = T extends Types.Array<any> ? AnyArray<Unpacked<T>> : T;
|
|
939
945
|
|
|
946
|
+
class MixedSchemaTypeOptions extends SchemaTypeOptions<Schema.Types.Mixed> {
|
|
947
|
+
type: typeof Schema.Types.Mixed;
|
|
948
|
+
}
|
|
949
|
+
|
|
940
950
|
export class SchemaTypeOptions<T> {
|
|
941
951
|
type?:
|
|
942
|
-
|
|
952
|
+
T extends string ? StringSchemaDefinition :
|
|
943
953
|
T extends number ? NumberSchemaDefinition :
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
954
|
+
T extends boolean ? BooleanSchemaDefinition :
|
|
955
|
+
T extends NativeDate ? DateSchemaDefinition :
|
|
956
|
+
T extends Map<any, any> ? SchemaDefinition<typeof Map> :
|
|
957
|
+
T extends Buffer ? SchemaDefinition<typeof Buffer> :
|
|
958
|
+
T extends Types.ObjectId ? ObjectIdSchemaDefinition :
|
|
959
|
+
T extends Types.ObjectId[] ? AnyArray<ObjectIdSchemaDefinition> | AnyArray<SchemaTypeOptions<ObjectId>> :
|
|
960
|
+
T extends object[] ? (AnyArray<Schema<any, any, any>> | AnyArray<SchemaDefinition<Unpacked<T>>> | AnyArray<SchemaTypeOptions<Unpacked<T>>>) :
|
|
961
|
+
T extends string[] ? AnyArray<StringSchemaDefinition> | AnyArray<SchemaTypeOptions<string>> :
|
|
962
|
+
T extends number[] ? AnyArray<NumberSchemaDefinition> | AnyArray<SchemaTypeOptions<number>> :
|
|
963
|
+
T extends boolean[] ? AnyArray<BooleanSchemaDefinition> | AnyArray<SchemaTypeOptions<boolean>> :
|
|
964
|
+
T extends Function[] ? AnyArray<Function | string> | AnyArray<SchemaTypeOptions<Unpacked<T>>> :
|
|
965
|
+
T | typeof SchemaType | Schema<any, any, any> | SchemaDefinition<T> | Function | AnyArray<Function>;
|
|
956
966
|
|
|
957
967
|
/** Defines a virtual with the given name that gets/sets this path. */
|
|
958
968
|
alias?: string;
|
|
@@ -974,7 +984,7 @@ declare module 'mongoose' {
|
|
|
974
984
|
* The default value for this path. If a function, Mongoose executes the function
|
|
975
985
|
* and uses the return value as the default.
|
|
976
986
|
*/
|
|
977
|
-
default?: ExtractMongooseArray<T> | ((this: any, doc: any) => Partial<ExtractMongooseArray<T>>);
|
|
987
|
+
default?: T extends Schema.Types.Mixed ? ({} | ((this: any, doc: any) => any)) : (ExtractMongooseArray<T> | ((this: any, doc: any) => Partial<ExtractMongooseArray<T>>));
|
|
978
988
|
|
|
979
989
|
/**
|
|
980
990
|
* The model that `populate()` should use if populating this path.
|
|
@@ -1097,7 +1107,7 @@ declare module 'mongoose' {
|
|
|
1097
1107
|
export type PopulatedDoc<
|
|
1098
1108
|
PopulatedType,
|
|
1099
1109
|
RawId extends RefType = (PopulatedType extends { _id?: RefType; } ? NonNullable<PopulatedType['_id']> : mongoose.Types.ObjectId) | undefined
|
|
1100
|
-
|
|
1110
|
+
> = PopulatedType | RawId;
|
|
1101
1111
|
|
|
1102
1112
|
interface IndexOptions extends mongodb.CreateIndexesOptions {
|
|
1103
1113
|
/**
|
|
@@ -1465,17 +1475,17 @@ declare module 'mongoose' {
|
|
|
1465
1475
|
}
|
|
1466
1476
|
}
|
|
1467
1477
|
|
|
1468
|
-
type ReturnsNewDoc = { new: true } | { returnOriginal: false } | {returnDocument: 'after'};
|
|
1478
|
+
type ReturnsNewDoc = { new: true } | { returnOriginal: false } | { returnDocument: 'after' };
|
|
1469
1479
|
|
|
1470
1480
|
type QueryWithHelpers<ResultType, DocType, THelpers = {}, RawDocType = DocType> = Query<ResultType, DocType, THelpers, RawDocType> & THelpers;
|
|
1471
1481
|
|
|
1472
|
-
type UnpackedIntersection<T, U> = T extends (infer A)[]
|
|
1482
|
+
type UnpackedIntersection<T, U> = T extends null ? null : T extends (infer A)[]
|
|
1473
1483
|
? (Omit<A, keyof U> & U)[]
|
|
1474
1484
|
: keyof U extends never
|
|
1475
|
-
|
|
1476
|
-
|
|
1485
|
+
? T
|
|
1486
|
+
: Omit<T, keyof U> & U;
|
|
1477
1487
|
|
|
1478
|
-
type ProjectionFields<DocType> = {[Key in keyof Omit<LeanDocument<DocType>, '__v'>]?: any} & Record<string, any>;
|
|
1488
|
+
type ProjectionFields<DocType> = { [Key in keyof Omit<LeanDocument<DocType>, '__v'>]?: any } & Record<string, any>;
|
|
1479
1489
|
|
|
1480
1490
|
class Query<ResultType, DocType, THelpers = {}, RawDocType = DocType> {
|
|
1481
1491
|
_mongooseOptions: MongooseQueryOptions;
|
|
@@ -1774,8 +1784,8 @@ declare module 'mongoose' {
|
|
|
1774
1784
|
polygon(path: string, ...coordinatePairs: number[][]): this;
|
|
1775
1785
|
|
|
1776
1786
|
/** Specifies paths which should be populated with other documents. */
|
|
1777
|
-
populate<Paths = {}>(path: string | string[], select?: string | any, model?: string | Model<any, THelpers>, match?: any): QueryWithHelpers<UnpackedIntersection<ResultType, Paths>, DocType, THelpers, RawDocType
|
|
1778
|
-
populate<Paths = {}>(options: PopulateOptions | (PopulateOptions | string)[]): QueryWithHelpers<UnpackedIntersection<ResultType, Paths>, DocType, THelpers, RawDocType
|
|
1787
|
+
populate<Paths = {}>(path: string | string[], select?: string | any, model?: string | Model<any, THelpers>, match?: any): QueryWithHelpers<UnpackedIntersection<ResultType, Paths>, DocType, THelpers, UnpackedIntersection<RawDocType, Paths>>;
|
|
1788
|
+
populate<Paths = {}>(options: PopulateOptions | (PopulateOptions | string)[]): QueryWithHelpers<UnpackedIntersection<ResultType, Paths>, DocType, THelpers, UnpackedIntersection<RawDocType, Paths>>;
|
|
1779
1789
|
|
|
1780
1790
|
/** Get/set the current projection (AKA fields). Pass `null` to remove the current projection. */
|
|
1781
1791
|
projection(): ProjectionFields<DocType> | null;
|
|
@@ -1965,10 +1975,10 @@ declare module 'mongoose' {
|
|
|
1965
1975
|
$or?: Array<FilterQuery<T>>;
|
|
1966
1976
|
/** @see https://docs.mongodb.com/manual/reference/operator/query/text */
|
|
1967
1977
|
$text?: {
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1978
|
+
$search: string;
|
|
1979
|
+
$language?: string;
|
|
1980
|
+
$caseSensitive?: boolean;
|
|
1981
|
+
$diacriticSensitive?: boolean;
|
|
1972
1982
|
};
|
|
1973
1983
|
/** @see https://docs.mongodb.com/manual/reference/operator/query/where/#op._S_where */
|
|
1974
1984
|
$where?: string | Function;
|
|
@@ -1985,7 +1995,7 @@ declare module 'mongoose' {
|
|
|
1985
1995
|
type _FilterQuery<T> = {
|
|
1986
1996
|
[P in keyof T]?: Condition<T[P]>;
|
|
1987
1997
|
} &
|
|
1988
|
-
|
|
1998
|
+
RootQuerySelector<T>;
|
|
1989
1999
|
|
|
1990
2000
|
/**
|
|
1991
2001
|
* Filter query to select the documents that match the query
|
|
@@ -2032,21 +2042,21 @@ declare module 'mongoose' {
|
|
|
2032
2042
|
|
|
2033
2043
|
/** @see https://docs.mongodb.com/manual/reference/operator/update-bitwise/ */
|
|
2034
2044
|
$bit?: {
|
|
2035
|
-
|
|
2045
|
+
[key: string]: { [key in 'and' | 'or' | 'xor']?: number };
|
|
2036
2046
|
};
|
|
2037
2047
|
};
|
|
2038
2048
|
|
|
2039
2049
|
type UpdateWithAggregationPipeline = UpdateAggregationStage[];
|
|
2040
2050
|
type UpdateAggregationStage = { $addFields: any } |
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2051
|
+
{ $set: any } |
|
|
2052
|
+
{ $project: any } |
|
|
2053
|
+
{ $unset: any } |
|
|
2054
|
+
{ $replaceRoot: any } |
|
|
2055
|
+
{ $replaceWith: any };
|
|
2046
2056
|
|
|
2047
2057
|
type __UpdateDefProperty<T> =
|
|
2048
2058
|
[Extract<T, mongodb.ObjectId>] extends [never] ? T :
|
|
2049
|
-
|
|
2059
|
+
T | string;
|
|
2050
2060
|
type _UpdateQueryDef<T> = {
|
|
2051
2061
|
[K in keyof T]?: __UpdateDefProperty<T[K]>;
|
|
2052
2062
|
};
|
|
@@ -2062,28 +2072,28 @@ declare module 'mongoose' {
|
|
|
2062
2072
|
|
|
2063
2073
|
export type DocumentDefinition<T> = {
|
|
2064
2074
|
[K in keyof Omit<T, Exclude<keyof Document, '_id' | 'id' | '__v'>>]:
|
|
2065
|
-
|
|
2075
|
+
[Extract<T[K], mongodb.ObjectId>] extends [never]
|
|
2066
2076
|
? T[K] extends TreatAsPrimitives
|
|
2067
2077
|
? T[K]
|
|
2068
2078
|
: LeanDocumentElement<T[K]>
|
|
2069
2079
|
: T[K] | string;
|
|
2070
|
-
|
|
2080
|
+
};
|
|
2071
2081
|
|
|
2072
2082
|
export type FlattenMaps<T> = {
|
|
2073
2083
|
[K in keyof T]: T[K] extends Map<any, any>
|
|
2074
2084
|
? AnyObject : T[K] extends TreatAsPrimitives
|
|
2075
|
-
|
|
2085
|
+
? T[K] : FlattenMaps<T[K]>;
|
|
2076
2086
|
};
|
|
2077
2087
|
|
|
2078
2088
|
type actualPrimitives = string | boolean | number | bigint | symbol | null | undefined;
|
|
2079
2089
|
type TreatAsPrimitives = actualPrimitives |
|
|
2080
|
-
|
|
2090
|
+
NativeDate | RegExp | symbol | Error | BigInt | Types.ObjectId;
|
|
2081
2091
|
|
|
2082
2092
|
type LeanType<T> =
|
|
2083
2093
|
0 extends (1 & T) ? T : // any
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2094
|
+
T extends TreatAsPrimitives ? T : // primitives
|
|
2095
|
+
T extends Types.Subdocument ? Omit<LeanDocument<T>, '$isSingleNested' | 'ownerDocument' | 'parent'> : // subdocs
|
|
2096
|
+
LeanDocument<T>; // Documents and everything else
|
|
2087
2097
|
|
|
2088
2098
|
type LeanArray<T extends unknown[]> = T extends unknown[][] ? LeanArray<T[number]>[] : LeanType<T[number]>[];
|
|
2089
2099
|
|
|
@@ -2096,8 +2106,8 @@ declare module 'mongoose' {
|
|
|
2096
2106
|
// This is required for PopulatedDoc.
|
|
2097
2107
|
type LeanDocumentElement<T> =
|
|
2098
2108
|
T extends unknown[] ? LeanArray<T> : // Array
|
|
2099
|
-
|
|
2100
|
-
|
|
2109
|
+
T extends Document ? LeanDocument<T> : // Subdocument
|
|
2110
|
+
T;
|
|
2101
2111
|
|
|
2102
2112
|
export type SchemaDefinitionType<T> = T extends Document ? Omit<T, Exclude<keyof Document, '_id' | 'id' | '__v'>> : T;
|
|
2103
2113
|
|
|
@@ -2110,160 +2120,13 @@ declare module 'mongoose' {
|
|
|
2110
2120
|
|
|
2111
2121
|
export type LeanDocumentOrArray<T> = 0 extends (1 & T) ? T :
|
|
2112
2122
|
T extends unknown[] ? LeanDocument<T[number]>[] :
|
|
2113
|
-
|
|
2114
|
-
|
|
2123
|
+
T extends Document ? LeanDocument<T> :
|
|
2124
|
+
T;
|
|
2115
2125
|
|
|
2116
2126
|
export type LeanDocumentOrArrayWithRawType<T, RawDocType> = 0 extends (1 & T) ? T :
|
|
2117
2127
|
T extends unknown[] ? RawDocType[] :
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
class Aggregate<R> {
|
|
2122
|
-
/**
|
|
2123
|
-
* Returns an asyncIterator for use with [`for/await/of` loops](https://thecodebarbarian.com/getting-started-with-async-iterators-in-node-js
|
|
2124
|
-
* You do not need to call this function explicitly, the JavaScript runtime
|
|
2125
|
-
* will call it for you.
|
|
2126
|
-
*/
|
|
2127
|
-
[Symbol.asyncIterator](): AsyncIterableIterator<Unpacked<R>>;
|
|
2128
|
-
|
|
2129
|
-
/**
|
|
2130
|
-
* Sets an option on this aggregation. This function will be deprecated in a
|
|
2131
|
-
* future release. */
|
|
2132
|
-
addCursorFlag(flag: string, value: boolean): this;
|
|
2133
|
-
|
|
2134
|
-
/**
|
|
2135
|
-
* Appends a new $addFields operator to this aggregate pipeline.
|
|
2136
|
-
* Requires MongoDB v3.4+ to work
|
|
2137
|
-
*/
|
|
2138
|
-
addFields(arg: PipelineStage.AddFields['$addFields']): this;
|
|
2139
|
-
|
|
2140
|
-
/** Sets the allowDiskUse option for the aggregation query (ignored for < 2.6.0) */
|
|
2141
|
-
allowDiskUse(value: boolean): this;
|
|
2142
|
-
|
|
2143
|
-
/** Appends new operators to this aggregate pipeline */
|
|
2144
|
-
append(...args: any[]): this;
|
|
2145
|
-
|
|
2146
|
-
/**
|
|
2147
|
-
* Executes the query returning a `Promise` which will be
|
|
2148
|
-
* resolved with either the doc(s) or rejected with the error.
|
|
2149
|
-
* Like [`.then()`](#query_Query-then), but only takes a rejection handler.
|
|
2150
|
-
*/
|
|
2151
|
-
catch: Promise<R>['catch'];
|
|
2152
|
-
|
|
2153
|
-
/** Adds a collation. */
|
|
2154
|
-
collation(options: mongodb.CollationOptions): this;
|
|
2155
|
-
|
|
2156
|
-
/** Appends a new $count operator to this aggregate pipeline. */
|
|
2157
|
-
count(countName: PipelineStage.Count['$count']): this;
|
|
2158
|
-
|
|
2159
|
-
/**
|
|
2160
|
-
* Sets the cursor option for the aggregation query (ignored for < 2.6.0).
|
|
2161
|
-
*/
|
|
2162
|
-
cursor<DocType = any>(options?: Record<string, unknown>): Cursor<DocType>;
|
|
2163
|
-
|
|
2164
|
-
/** Executes the aggregate pipeline on the currently bound Model. */
|
|
2165
|
-
exec(callback?: Callback<R>): Promise<R>;
|
|
2166
|
-
|
|
2167
|
-
/** Execute the aggregation with explain */
|
|
2168
|
-
explain(callback?: Callback): Promise<any>;
|
|
2169
|
-
explain(verbosity?: string, callback?: Callback): Promise<any>;
|
|
2170
|
-
|
|
2171
|
-
/** Combines multiple aggregation pipelines. */
|
|
2172
|
-
facet(options: PipelineStage.Facet['$facet']): this;
|
|
2173
|
-
|
|
2174
|
-
/** Appends new custom $graphLookup operator(s) to this aggregate pipeline, performing a recursive search on a collection. */
|
|
2175
|
-
graphLookup(options: PipelineStage.GraphLookup['$graphLookup']): this;
|
|
2176
|
-
|
|
2177
|
-
/** Appends new custom $group operator to this aggregate pipeline. */
|
|
2178
|
-
group(arg: PipelineStage.Group['$group']): this;
|
|
2179
|
-
|
|
2180
|
-
/** Sets the hint option for the aggregation query (ignored for < 3.6.0) */
|
|
2181
|
-
hint(value: Record<string, unknown> | string): this;
|
|
2182
|
-
|
|
2183
|
-
/**
|
|
2184
|
-
* Appends a new $limit operator to this aggregate pipeline.
|
|
2185
|
-
* @param num maximum number of records to pass to the next stage
|
|
2186
|
-
*/
|
|
2187
|
-
limit(num: PipelineStage.Limit['$limit']): this;
|
|
2188
|
-
|
|
2189
|
-
/** Appends new custom $lookup operator to this aggregate pipeline. */
|
|
2190
|
-
lookup(options: PipelineStage.Lookup['$lookup']): this;
|
|
2191
|
-
|
|
2192
|
-
/**
|
|
2193
|
-
* Appends a new custom $match operator to this aggregate pipeline.
|
|
2194
|
-
* @param arg $match operator contents
|
|
2195
|
-
*/
|
|
2196
|
-
match(arg: PipelineStage.Match['$match']): this;
|
|
2197
|
-
|
|
2198
|
-
/**
|
|
2199
|
-
* Binds this aggregate to a model.
|
|
2200
|
-
* @param model the model to which the aggregate is to be bound
|
|
2201
|
-
*/
|
|
2202
|
-
model(model: any): this;
|
|
2203
|
-
|
|
2204
|
-
/**
|
|
2205
|
-
* Append a new $near operator to this aggregation pipeline
|
|
2206
|
-
* @param arg $near operator contents
|
|
2207
|
-
*/
|
|
2208
|
-
near(arg: { near?: number[]; distanceField: string; maxDistance?: number; query?: Record<string, any>; includeLocs?: string; num?: number; uniqueDocs?: boolean }): this;
|
|
2209
|
-
|
|
2210
|
-
/** Returns the current pipeline */
|
|
2211
|
-
pipeline(): any[];
|
|
2212
|
-
|
|
2213
|
-
/** Appends a new $project operator to this aggregate pipeline. */
|
|
2214
|
-
project(arg: PipelineStage.Project['$project']): this;
|
|
2215
|
-
|
|
2216
|
-
/** Sets the readPreference option for the aggregation query. */
|
|
2217
|
-
read(pref: string | mongodb.ReadPreferenceMode, tags?: any[]): this;
|
|
2218
|
-
|
|
2219
|
-
/** Sets the readConcern level for the aggregation query. */
|
|
2220
|
-
readConcern(level: string): this;
|
|
2221
|
-
|
|
2222
|
-
/** Appends a new $redact operator to this aggregate pipeline. */
|
|
2223
|
-
redact(expression: any, thenExpr: string | any, elseExpr: string | any): this;
|
|
2224
|
-
|
|
2225
|
-
/** Appends a new $replaceRoot operator to this aggregate pipeline. */
|
|
2226
|
-
replaceRoot(newRoot: PipelineStage.ReplaceRoot['$replaceRoot']['newRoot'] | string): this;
|
|
2227
|
-
|
|
2228
|
-
/**
|
|
2229
|
-
* Helper for [Atlas Text Search](https://docs.atlas.mongodb.com/reference/atlas-search/tutorial/)'s
|
|
2230
|
-
* `$search` stage.
|
|
2231
|
-
*/
|
|
2232
|
-
search(options: PipelineStage.Search['$search']): this;
|
|
2233
|
-
|
|
2234
|
-
/** Lets you set arbitrary options, for middleware or plugins. */
|
|
2235
|
-
option(value: Record<string, unknown>): this;
|
|
2236
|
-
|
|
2237
|
-
/** Appends new custom $sample operator to this aggregate pipeline. */
|
|
2238
|
-
sample(size: number): this;
|
|
2239
|
-
|
|
2240
|
-
/** Sets the session for this aggregation. Useful for [transactions](/docs/transactions.html). */
|
|
2241
|
-
session(session: mongodb.ClientSession | null): this;
|
|
2242
|
-
|
|
2243
|
-
/**
|
|
2244
|
-
* Appends a new $skip operator to this aggregate pipeline.
|
|
2245
|
-
* @param num number of records to skip before next stage
|
|
2246
|
-
*/
|
|
2247
|
-
skip(num: number): this;
|
|
2248
|
-
|
|
2249
|
-
/** Appends a new $sort operator to this aggregate pipeline. */
|
|
2250
|
-
sort(arg: string | Record<string, SortValues> | PipelineStage.Sort['$sort']): this;
|
|
2251
|
-
|
|
2252
|
-
/** Provides promise for aggregate. */
|
|
2253
|
-
then: Promise<R>['then'];
|
|
2254
|
-
|
|
2255
|
-
/**
|
|
2256
|
-
* Appends a new $sortByCount operator to this aggregate pipeline. Accepts either a string field name
|
|
2257
|
-
* or a pipeline object.
|
|
2258
|
-
*/
|
|
2259
|
-
sortByCount(arg: string | any): this;
|
|
2260
|
-
|
|
2261
|
-
/** Appends new $unionWith operator to this aggregate pipeline. */
|
|
2262
|
-
unionWith(options: any): this;
|
|
2263
|
-
|
|
2264
|
-
/** Appends new custom $unwind operator(s) to this aggregate pipeline. */
|
|
2265
|
-
unwind(...args: PipelineStage.Unwind['$unwind'][]): this;
|
|
2266
|
-
}
|
|
2128
|
+
T extends Document ? RawDocType :
|
|
2129
|
+
T;
|
|
2267
2130
|
|
|
2268
2131
|
class SchemaType {
|
|
2269
2132
|
/** SchemaType constructor */
|