-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
refactor: move find command building all into the find operation #2643
Conversation
6c723d3
to
b66c07a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! A few small nits but nothing to hold up a merge
src/operations/find.ts
Outdated
|
||
if (options.projection) { | ||
let projection = options.projection; | ||
if (projection && !Buffer.isBuffer(projection) && Array.isArray(projection)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (projection && !Buffer.isBuffer(projection) && Array.isArray(projection)) { | |
if (projection && Array.isArray(projection)) { |
Nit: Shouldn't Array.isArray
imply !Buffer.isBuffer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/operations/find.ts
Outdated
|
||
if (typeof options.limit === 'number') { | ||
if (options.limit < 0) { | ||
findCommand.limit = Math.abs(options.limit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findCommand.limit = Math.abs(options.limit); | |
findCommand.limit = -options.limit; |
Nit: I'd guess using the -
operator is faster than Math.abs when we know something is negative, but also probably a fairly negligible improvement. Also applies below in the options.batchSize < 0
condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. I left two Math.abs
in there where I felt it improved readability (Math.abs(batchSize) < Math.abs(limit)
looks better than -batchSize < -limit
IMO)
One of the changes made in merging the core and native drivers was to merge the wire protocol methods for executing find operations. A vestigial piece of this was that the find command was being built in the wire protocol layer, rather than the operation layer. This patch teases these two apart, so that the `query` wire protocol method only creates and executes an `OP_QUERY` message, and the modern and legacy find commands are built in the find operation's definition itself. NODE-2900
b66c07a
to
eb020e0
Compare
One of the changes made in merging the core and native drivers was to merge the wire protocol methods for executing find operations. A vestigial piece of this was that the find command was being built in the wire protocol layer, rather than the operation layer. This patch teases these two apart, so that the
query
wire protocol method only creates and executes anOP_QUERY
message, and the modern and legacy find commands are built in the find operation's definition itself.NODE-2900