Skip to content

Commit

Permalink
Merge branch 'master' into 7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 29, 2023
2 parents d9a4bc4 + 84e79b9 commit a92e8e8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
6 changes: 6 additions & 0 deletions test/types/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1177,3 +1177,9 @@ function gh13702() {
const schema = new Schema({ name: String });
expectType<[IndexDefinition, IndexOptions][]>(schema.indexes());
}

function gh13780() {
const schema = new Schema({ num: Schema.Types.BigInt });
type InferredType = InferSchemaType<typeof schema>;
expectType<bigint | undefined>(null as unknown as InferredType['num']);
}
24 changes: 13 additions & 11 deletions types/inferschematype.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,16 @@ type ResolvePathType<PathValueType, Options extends SchemaTypeOptions<PathValueT
PathValueType extends 'decimal128' | 'Decimal128' | typeof Schema.Types.Decimal128 ? Types.Decimal128 :
IfEquals<PathValueType, Schema.Types.Decimal128> extends true ? Types.Decimal128 :
IfEquals<PathValueType, Types.Decimal128> extends true ? Types.Decimal128 :
PathValueType extends 'uuid' | 'UUID' | typeof Schema.Types.UUID ? Buffer :
IfEquals<PathValueType, Schema.Types.UUID> extends true ? Buffer :
PathValueType extends MapConstructor ? Map<string, ResolvePathType<Options['of']>> :
IfEquals<PathValueType, typeof Schema.Types.Map> extends true ? Map<string, ResolvePathType<Options['of']>> :
PathValueType extends ArrayConstructor ? any[] :
PathValueType extends typeof Schema.Types.Mixed ? any:
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
IfEquals<PathValueType, {}> extends true ? any:
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
PathValueType extends Record<string, any> ? ObtainDocumentType<PathValueType, any, { typeKey: TypeKey }> :
unknown;
IfEquals<PathValueType, Schema.Types.BigInt> extends true ? bigint :
PathValueType extends 'bigint' | 'BigInt' | typeof Schema.Types.BigInt ? bigint :
PathValueType extends 'uuid' | 'UUID' | typeof Schema.Types.UUID ? Buffer :
IfEquals<PathValueType, Schema.Types.UUID> extends true ? Buffer :
PathValueType extends MapConstructor ? Map<string, ResolvePathType<Options['of']>> :
IfEquals<PathValueType, typeof Schema.Types.Map> extends true ? Map<string, ResolvePathType<Options['of']>> :
PathValueType extends ArrayConstructor ? any[] :
PathValueType extends typeof Schema.Types.Mixed ? any:
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
IfEquals<PathValueType, {}> extends true ? any:
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
PathValueType extends Record<string, any> ? ObtainDocumentType<PathValueType, any, { typeKey: TypeKey }> :
unknown;
15 changes: 15 additions & 0 deletions types/pipelinestage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare module 'mongoose' {
| PipelineStage.ReplaceWith
| PipelineStage.Sample
| PipelineStage.Search
| PipelineStage.SearchMeta
| PipelineStage.Set
| PipelineStage.SetWindowFields
| PipelineStage.Skip
Expand Down Expand Up @@ -239,6 +240,20 @@ declare module 'mongoose' {
}
}

export interface SearchMeta {
/** [`$searchMeta` reference](https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#mongodb-pipeline-pipe.-searchMeta) */
$searchMeta: {
index?: string;
highlight?: {
/** [`highlightPath` reference](https://docs.atlas.mongodb.com/atlas-search/path-construction/#multiple-field-search) */
path: string | string[] | { value: string, multi: string };
maxCharsToExamine?: number;
maxNumPassages?: number;
};
[operator: string]: any;
}
}

export interface Set {
/** [`$set` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/) */
$set: Record<string, AnyExpression | any>
Expand Down
8 changes: 8 additions & 0 deletions types/schematypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ declare module 'mongoose' {
enum(vals: string[] | number[]): this;
}

class BigInt extends SchemaType {
/** This schema type's name, to defend against minifiers that mangle function names. */
static schemaName: 'BigInt';

/** Default options for this SchemaType */
defaultOptions: Record<string, any>;
}

class Boolean extends SchemaType {
/** This schema type's name, to defend against minifiers that mangle function names. */
static schemaName: 'Boolean';
Expand Down

0 comments on commit a92e8e8

Please sign in to comment.