Skip to content

Commit ef012b3

Browse files
authored
Merge pull request #13931 from t1bb4r/master
fix(types): add insertMany array overload with options
2 parents d948776 + f6db790 commit ef012b3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

test/types/models.test.ts

+14
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ async function insertManyTest() {
8282
expectAssignable<Error | Object | ReturnType<(typeof Test)['hydrate']>>(res2.mongoose.results[0]);
8383
}
8484

85+
function gh13930() {
86+
interface ITest {
87+
foo: string;
88+
}
89+
90+
const TestSchema = new Schema<ITest>({
91+
foo: { type: String, required: true }
92+
});
93+
94+
const Test = connection.model<ITest>('Test', TestSchema);
95+
96+
Test.insertMany<{foo: string}>([{ foo: 'bar' }], { });
97+
}
98+
8599
function gh10074() {
86100
interface IDog {
87101
breed: string;

types/models.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ declare module 'mongoose' {
400400
doc: DocContents,
401401
options: InsertManyOptions
402402
): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>>;
403+
insertMany<DocContents = TRawDocType>(
404+
docs: Array<DocContents | TRawDocType>,
405+
options: InsertManyOptions
406+
): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>>;
403407
insertMany<DocContents = TRawDocType>(
404408
doc: DocContents
405409
): Promise<

0 commit comments

Comments
 (0)