Skip to content

Commit 731630f

Browse files
committed
chore: comments on responses
1 parent 970a92d commit 731630f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/cmap/wire_protocol/responses.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,3 @@ export class ClientBulkWriteCursorResponse extends CursorResponse {
391391
return this.get('writeConcernError', BSONType.object, false);
392392
}
393393
}
394-
395-
export class CreateSearchIndexesResponse extends MongoDBResponse {
396-
get indexesCreated() {
397-
return this.get('indexesCreated', BSONType.array);
398-
}
399-
}

src/operations/search_indexes/create.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { type Document } from '../../bson';
1+
import { BSONType, type Document, parseUtf8ValidationOption } from '../../bson';
22
import { type Connection } from '../../cmap/connection';
3-
import { CreateSearchIndexesResponse } from '../../cmap/wire_protocol/responses';
3+
import { MongoDBResponse } from '../../cmap/wire_protocol/responses';
44
import type { Collection } from '../../collection';
55
import type { ServerCommandOptions } from '../../sdam/server';
66
import type { ClientSession } from '../../sessions';
@@ -21,6 +21,12 @@ export interface SearchIndexDescription extends Document {
2121
type?: string;
2222
}
2323

24+
class CreateSearchIndexesResponse extends MongoDBResponse {
25+
get indexesCreated() {
26+
return this.get('indexesCreated', BSONType.array);
27+
}
28+
}
29+
2430
/** @internal */
2531
export class CreateSearchIndexesOperation extends ModernizedOperation<string[]> {
2632
override SERVER_COMMAND_RESPONSE_TYPE = CreateSearchIndexesResponse;
@@ -47,7 +53,10 @@ export class CreateSearchIndexesOperation extends ModernizedOperation<string[]>
4753
}
4854

4955
override handleOk(response: InstanceType<typeof this.SERVER_COMMAND_RESPONSE_TYPE>): string[] {
50-
const indexesCreated = response.indexesCreated?.toObject();
56+
const indexesCreated = response.indexesCreated?.toObject({
57+
...this.bsonOptions,
58+
validation: parseUtf8ValidationOption(this.bsonOptions)
59+
});
5160
return indexesCreated ? Object.entries(indexesCreated).map(([_key, val]) => val.name) : [];
5261
}
5362

0 commit comments

Comments
 (0)