Skip to content

refactor: have FindOneOperation extend CommandOperation #2604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/operations/find_one.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import { OperationBase } from './operation';
import type { Callback } from '../utils';
import { Document, resolveBSONOptions } from '../bson';
import type { Document } from '../bson';
import type { Collection } from '../collection';
import type { FindOptions } from './find';
import { MongoError } from '../error';
import type { Server } from '../sdam/server';
import { CommandOperation } from './command';

/** @internal */
export class FindOneOperation extends OperationBase<FindOptions, Document> {
export class FindOneOperation extends CommandOperation<FindOptions, Document> {
collection: Collection;
query: Document;

constructor(collection: Collection, query: Document, options: FindOptions) {
super(options);
super(collection, options);

this.collection = collection;
this.query = query;

// Assign BSON serialize options to OperationBase, preferring options over collection options
this.bsonOptions = resolveBSONOptions(options, collection);
}

execute(server: Server, callback: Callback<Document>): void {
Expand Down