Skip to content

Commit 7f257d5

Browse files
chore: fix lint
1 parent 7bba900 commit 7f257d5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/operations/update.ts

Lines changed: 3 additions & 2 deletions
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';
@@ -32,7 +33,7 @@ export interface UpdateResult<TSchema = Document> {
3233
acknowledged: boolean;
3334
/** The number of documents that matched the filter */
3435
matchedCount: number;
35-
/** The number of documents that were modified */
36+
/** The number of documents that were modified */
3637
modifiedCount: number;
3738
/** The number of documents that were upserted */
3839
upsertedCount: number;

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { expectAssignable, expectError, expectNotAssignable, expectNotType } fro
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)