File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -153,4 +153,20 @@ export class Session extends EventEmitter<SessionEvents> {
153153 get connectedAtlasCluster ( ) : AtlasClusterConnectionInfo | undefined {
154154 return this . connectionManager . currentConnectionState . connectedAtlasCluster ;
155155 }
156+
157+ async isSearchIndexSupported ( ) : Promise < boolean > {
158+ try {
159+ const dummyDatabase = `db-${ Date . now ( ) } ` ;
160+ const dummyCollection = `coll-${ Date . now ( ) } ` ;
161+ // If a cluster supports search indexes, the call below will succeed
162+ // with a cursor otherwise will throw a MongoServerError
163+ await this . serviceProvider . getSearchIndexes ( dummyDatabase , dummyCollection ) ;
164+ return true ;
165+ } catch ( error ) {
166+ if ( error instanceof Error && "codeName" in error && error . codeName === "SearchNotEnabled" ) {
167+ return false ;
168+ }
169+ throw error ;
170+ }
171+ }
156172}
You can’t perform that action at this time.
0 commit comments