Skip to content

Commit b1dcd0b

Browse files
committed
fix: handle oid filter case
1 parent f6aa204 commit b1dcd0b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/operations/find_one_operation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export class FindOneOperation<TSchema = any> extends CommandOperation<TSchema> {
3333
constructor(db: Db, collectionName: string, filter: Document, options: FindOneOptions = {}) {
3434
super(db, options);
3535
this.namespace = new MongoDBNamespace(db.databaseName, collectionName);
36-
this.filter = filter;
36+
// special case passing in an ObjectId as a filter
37+
this.filter = filter != null && filter._bsontype === 'ObjectId' ? { _id: filter } : filter;
3738
this.options = { ...options };
3839
this.deserializationOptions = {
3940
...pluckBSONSerializeOptions(options),

0 commit comments

Comments
 (0)