Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(find): use
FindOperation
for finds
This changeset introduces support for using an operation for find operations. Unlike other operations, this one is still in progress in terms of becoming a proper subclass of `CommandOperationV2`. Since we must maintain support for legacy versions of the server, we cannot simply reuse the command operation.
- Loading branch information
1 parent
0f88582
commit 6acef6d
Showing
7 changed files
with
79 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
const OperationBase = require('./operation').OperationBase; | ||
const Aspect = require('./operation').Aspect; | ||
const defineAspects = require('./operation').defineAspects; | ||
|
||
class FindOperation extends OperationBase { | ||
constructor(collection, ns, command, options) { | ||
super(options); | ||
|
||
this.ns = ns; | ||
this.cmd = command; | ||
} | ||
|
||
execute(server, callback) { | ||
// copied from `CommandOperationV2`, to be subclassed in the future | ||
this.server = server; | ||
|
||
const cursorState = this.cursorState || {}; | ||
|
||
// TOOD: use `MongoDBNamespace` through and through | ||
server.query(this.ns.toString(), this.cmd, cursorState, this.options, callback); | ||
} | ||
} | ||
|
||
defineAspects(FindOperation, [ | ||
Aspect.READ_OPERATION, | ||
Aspect.RETRYABLE, | ||
Aspect.EXECUTE_WITH_SELECTION, | ||
Aspect.SKIP_SESSION | ||
]); | ||
|
||
module.exports = FindOperation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters