diff --git a/test/types/models.test.ts b/test/types/models.test.ts index ff473840f1c..2e46de6eb76 100644 --- a/test/types/models.test.ts +++ b/test/types/models.test.ts @@ -853,3 +853,19 @@ async function gh14003() { await TestModel.validate({ name: 'foo' }, ['name']); await TestModel.validate({ name: 'foo' }, { pathsToSkip: ['name'] }); } + +async function gh13999() { + class RepositoryBase { + protected model: mongoose.Model; + + constructor(schemaModel: mongoose.Model) { + this.model = schemaModel; + } + + async insertMany(elems: T[]): Promise { + elems = await this.model.insertMany(elems, { session: null }); + return elems; + } + } + +} diff --git a/types/models.d.ts b/types/models.d.ts index 45f67138b46..2df347c9843 100644 --- a/types/models.d.ts +++ b/types/models.d.ts @@ -395,6 +395,10 @@ declare module 'mongoose' { docs: Array, options: InsertManyOptions & { rawResult: true; } ): Promise>>; + insertMany( + doc: Array, + options: InsertManyOptions + ): Promise>; insertMany( docs: Array, options: InsertManyOptions & { lean: true; }