Skip to content

Commit 94b7ae4

Browse files
chore: fix lint
1 parent 7bba900 commit 94b7ae4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/operations/update.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { Document, ObjectId } from '../bson';
1+
import type { Document } from '../bson';
22
import type { Collection } from '../collection';
33
import { MongoCompatibilityError, MongoInvalidArgumentError, MongoServerError } from '../error';
4+
import type { InferIdType } from '../mongo_types';
45
import type { Server } from '../sdam/server';
56
import type { ClientSession } from '../sessions';
67
import { Callback, hasAtomicOperators, MongoDBNamespace } from '../utils';

test/types/community/collection/updateX.test-d.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { expectAssignable, expectError, expectNotAssignable, expectNotType } from 'tsd';
1+
import { expectAssignable, expectError, expectNotAssignable, expectNotType, expectType } from 'tsd';
22

33
import type {
44
AddToSetOperators,
55
ArrayOperator,
6+
Collection,
67
MatchKeysAndValues,
78
PullAllOperator,
89
PullOperator,
@@ -423,3 +424,16 @@ export async function testPushWithId(): Promise<void> {
423424
}
424425
);
425426
}
427+
428+
{
429+
// NODE-5171 - UpdateResult is generic over the collection schema and infers the id type
430+
const collection = {} as any as Collection;
431+
expectAssignable<Promise<{ upsertedId: ObjectId | null }>>(collection.updateOne({}, {}));
432+
expectAssignable<Promise<{ upsertedId: ObjectId | null }>>(collection.updateMany({}, {}));
433+
434+
const collectionWithSchema = {} as any as Collection<{ _id: number }>;
435+
expectAssignable<Promise<{ upsertedId: number | null }>>(
436+
collectionWithSchema.updateOne({ _id: 1234 }, {})
437+
);
438+
expectAssignable<Promise<{ upsertedId: number | null }>>(collectionWithSchema.updateMany({}, {}));
439+
}

0 commit comments

Comments
 (0)