-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(NODE-5314): add search index helpers #3672
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
feat(NODE-5314): add search index helpers #3672
Conversation
* the `collection` portion of the namespace is defined and should only be | ||
* used in scenarios where this can be guaranteed. | ||
*/ | ||
export class MongoDBCollectionNamespace extends MongoDBNamespace { |
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.
This change is not necessary but without it, the operations added in this PR must either assert on the namespace's collection string being truthy or provide a default value, but in all cases the namespace has a collection defined (they're all operations defined on the collection).
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.
I have another thread where I mention we do not need this if we pass through the namespace instead of the collection instance, so let's address that first. But following up here let's unit test withCollection
& this class
listSearchIndexes( | ||
indexNameOrOptions?: string | ListSearchIndexesOptions, | ||
options?: ListSearchIndexesOptions | ||
): ListSearchIndexesCursor { |
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.
Since the return value is the same for all these methods so we should just have the union type argument and optional options
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.
That's not quite the same. Collapsing them into a single overload implies that listSearchIndexes(AggregateOptions, AggregateOptions)
is a valid signature. Overloading the method clarifies which combinations of arguments are valid.
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.
Calling the method with listSearchIndexes(options, options)
will work though, so I don't know if there's much risk to that implication. I think that the UX is reasonably clear without it
But if we do keep the overload the one after the first one doesn't have documentation, overloads each need their own tsdoc block
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.


Maybe this is my particular workflow, but I often peruse the overloads for methods by scrolling through the modal that pops up in vscode. I think it's beneficial to provide clear intended usages. I added an additional tsdoc comment for the new overload.
Also, listSearchIndexes(options, options)
won't work because the actual pipeline stage sent will be:
{ $listSearchIndexes: { name: <aggregation options > } }
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.
Yea that's fair, I think the union of types is equally clear, the possible inputs are listed in one popup, no scrolling needed.
Also, listSearchIndexes(options, options) won't work because the actual pipeline stage sent will be:
{ $listSearchIndexes: { name: <aggregation options > } }
From the option handling:
: typeof indexNameOrOptions === 'object'
? null
This case should set the name to null
and then the pipeline will be constructed correctly in the cursor since we test for name == null
.
* the `collection` portion of the namespace is defined and should only be | ||
* used in scenarios where this can be guaranteed. | ||
*/ | ||
export class MongoDBCollectionNamespace extends MongoDBNamespace { |
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.
I have another thread where I mention we do not need this if we pass through the namespace instead of the collection instance, so let's address that first. But following up here let's unit test withCollection
& this class
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.
Just some clarifying questions
} | ||
|
||
/** | ||
* @internal |
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.
Should these be @internal? Once released we're going to have to use them from mongosh, right?
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.
We don't want to release an untested API as public yet, so they're internal for now until we can manually e2e test them.
@internal
only strips things out of the Typescript definitions, everything will still be accessible. It might be slightly more inconvenient to work with in mongosh, but it should still work.
Is that alright with you?
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.
That's fine, I guess. I forked this branch so I can work with it locally in the meantime anyway.
c5fcc23
to
b66854c
Compare
Description
POC for mongodb/specifications#1423.
What is changing?
Is there new documentation needed for these changes?
No.
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript