Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the schema to accept typed SchemaDefinition #9789

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,14 +1037,14 @@ declare module 'mongoose' {

type MongooseQueryMiddleware = 'count' | 'deleteMany' | 'deleteOne' | 'find' | 'findOne' | 'findOneAndDelete' | 'findOneAndRemove' | 'findOneAndUpdate' | 'remove' | 'update' | 'updateOne' | 'updateMany';

class Schema<DocType extends Document = Document, M extends Model<DocType> = Model<DocType>> extends events.EventEmitter {
class Schema<DocType extends Document = Document, M extends Model<DocType> = Model<DocType>, SchemaDefModel = undefined> extends events.EventEmitter {
/**
* Create a new schema
*/
constructor(definition?: SchemaDefinition, options?: SchemaOptions);
constructor(definition?: SchemaDefinition<SchemaDefModel>, options?: SchemaOptions);

/** Adds key path / schema type pairs to this schema. */
add(obj: SchemaDefinition | Schema, prefix?: string): this;
add(obj: SchemaDefinition<SchemaDefModel> | Schema, prefix?: string): this;

/**
* Array of child schemas (from document arrays and single nested subdocs)
Expand Down