We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f6aa204 commit b1dcd0bCopy full SHA for b1dcd0b
1 file changed
src/operations/find_one_operation.ts
@@ -33,7 +33,8 @@ export class FindOneOperation<TSchema = any> extends CommandOperation<TSchema> {
33
constructor(db: Db, collectionName: string, filter: Document, options: FindOneOptions = {}) {
34
super(db, options);
35
this.namespace = new MongoDBNamespace(db.databaseName, collectionName);
36
- this.filter = filter;
+ // special case passing in an ObjectId as a filter
37
+ this.filter = filter != null && filter._bsontype === 'ObjectId' ? { _id: filter } : filter;
38
this.options = { ...options };
39
this.deserializationOptions = {
40
...pluckBSONSerializeOptions(options),
0 commit comments