Skip to content

Commit a92e8e8

Browse files
committed
Merge branch 'master' into 7.5
2 parents d9a4bc4 + 84e79b9 commit a92e8e8

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

test/types/schema.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,3 +1177,9 @@ function gh13702() {
11771177
const schema = new Schema({ name: String });
11781178
expectType<[IndexDefinition, IndexOptions][]>(schema.indexes());
11791179
}
1180+
1181+
function gh13780() {
1182+
const schema = new Schema({ num: Schema.Types.BigInt });
1183+
type InferredType = InferSchemaType<typeof schema>;
1184+
expectType<bigint | undefined>(null as unknown as InferredType['num']);
1185+
}

types/inferschematype.d.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,16 @@ type ResolvePathType<PathValueType, Options extends SchemaTypeOptions<PathValueT
215215
PathValueType extends 'decimal128' | 'Decimal128' | typeof Schema.Types.Decimal128 ? Types.Decimal128 :
216216
IfEquals<PathValueType, Schema.Types.Decimal128> extends true ? Types.Decimal128 :
217217
IfEquals<PathValueType, Types.Decimal128> extends true ? Types.Decimal128 :
218-
PathValueType extends 'uuid' | 'UUID' | typeof Schema.Types.UUID ? Buffer :
219-
IfEquals<PathValueType, Schema.Types.UUID> extends true ? Buffer :
220-
PathValueType extends MapConstructor ? Map<string, ResolvePathType<Options['of']>> :
221-
IfEquals<PathValueType, typeof Schema.Types.Map> extends true ? Map<string, ResolvePathType<Options['of']>> :
222-
PathValueType extends ArrayConstructor ? any[] :
223-
PathValueType extends typeof Schema.Types.Mixed ? any:
224-
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
225-
IfEquals<PathValueType, {}> extends true ? any:
226-
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
227-
PathValueType extends Record<string, any> ? ObtainDocumentType<PathValueType, any, { typeKey: TypeKey }> :
228-
unknown;
218+
IfEquals<PathValueType, Schema.Types.BigInt> extends true ? bigint :
219+
PathValueType extends 'bigint' | 'BigInt' | typeof Schema.Types.BigInt ? bigint :
220+
PathValueType extends 'uuid' | 'UUID' | typeof Schema.Types.UUID ? Buffer :
221+
IfEquals<PathValueType, Schema.Types.UUID> extends true ? Buffer :
222+
PathValueType extends MapConstructor ? Map<string, ResolvePathType<Options['of']>> :
223+
IfEquals<PathValueType, typeof Schema.Types.Map> extends true ? Map<string, ResolvePathType<Options['of']>> :
224+
PathValueType extends ArrayConstructor ? any[] :
225+
PathValueType extends typeof Schema.Types.Mixed ? any:
226+
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
227+
IfEquals<PathValueType, {}> extends true ? any:
228+
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
229+
PathValueType extends Record<string, any> ? ObtainDocumentType<PathValueType, any, { typeKey: TypeKey }> :
230+
unknown;

types/pipelinestage.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ declare module 'mongoose' {
2828
| PipelineStage.ReplaceWith
2929
| PipelineStage.Sample
3030
| PipelineStage.Search
31+
| PipelineStage.SearchMeta
3132
| PipelineStage.Set
3233
| PipelineStage.SetWindowFields
3334
| PipelineStage.Skip
@@ -239,6 +240,20 @@ declare module 'mongoose' {
239240
}
240241
}
241242

243+
export interface SearchMeta {
244+
/** [`$searchMeta` reference](https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#mongodb-pipeline-pipe.-searchMeta) */
245+
$searchMeta: {
246+
index?: string;
247+
highlight?: {
248+
/** [`highlightPath` reference](https://docs.atlas.mongodb.com/atlas-search/path-construction/#multiple-field-search) */
249+
path: string | string[] | { value: string, multi: string };
250+
maxCharsToExamine?: number;
251+
maxNumPassages?: number;
252+
};
253+
[operator: string]: any;
254+
}
255+
}
256+
242257
export interface Set {
243258
/** [`$set` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/) */
244259
$set: Record<string, AnyExpression | any>

types/schematypes.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,14 @@ declare module 'mongoose' {
311311
enum(vals: string[] | number[]): this;
312312
}
313313

314+
class BigInt extends SchemaType {
315+
/** This schema type's name, to defend against minifiers that mangle function names. */
316+
static schemaName: 'BigInt';
317+
318+
/** Default options for this SchemaType */
319+
defaultOptions: Record<string, any>;
320+
}
321+
314322
class Boolean extends SchemaType {
315323
/** This schema type's name, to defend against minifiers that mangle function names. */
316324
static schemaName: 'Boolean';

0 commit comments

Comments
 (0)