Skip to content

Commit 2847892

Browse files
docs: add docstring comments to 'comment' option
1 parent 20c9681 commit 2847892

File tree

9 files changed

+86
-16
lines changed

9 files changed

+86
-16
lines changed

src/change_stream.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,14 @@ export interface ChangeStreamCursorOptions extends AbstractCursorOptions {
403403
startAtOperationTime?: OperationTime;
404404
resumeAfter?: ResumeToken;
405405
startAfter?: boolean;
406-
407-
/** todo: add comment */
406+
/**
407+
* Comment to apply to the operation.
408+
*
409+
* In server versions <4.4, 'comment' must be string. A server
410+
* error will be thrown if any other type is provided.
411+
*
412+
* In server versions >=4.4, 'comment' can be any valid BSON type.
413+
*/
408414
comment?: any;
409415
}
410416

src/cmap/connection.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,15 @@ export interface GetMoreOptions extends CommandOptions {
124124
batchSize?: number;
125125
maxTimeMS?: number;
126126
maxAwaitTimeMS?: number;
127-
comment?: Document | string;
127+
/**
128+
* Comment to apply to the operation.
129+
*
130+
* In server versions <4.4, 'comment' must be string. A server
131+
* error will be thrown if any other type is provided.
132+
*
133+
* In server versions >=4.4, 'comment' can be any valid BSON type.
134+
*/
135+
comment?: any;
128136
}
129137

130138
/** @public */

src/cursor/abstract_cursor.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ export interface AbstractCursorOptions extends BSONSerializeOptions {
7777
readConcern?: ReadConcernLike;
7878
batchSize?: number;
7979
maxTimeMS?: number;
80+
/**
81+
* Comment to apply to the operation.
82+
*
83+
* In server versions <4.4, 'comment' must be string. A server
84+
* error will be thrown if any other type is provided.
85+
*
86+
* In server versions >=4.4, 'comment' can be any valid BSON type.
87+
*/
8088
comment?: any;
8189
tailable?: boolean;
8290
awaitData?: boolean;

src/operations/aggregate.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ export interface AggregateOptions extends CommandOperationOptions {
3131
hint?: Hint;
3232
/** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */
3333
let?: Document;
34-
/** Comment to apply to the operation. */
34+
/**
35+
* Comment to apply to the operation.
36+
*
37+
* In server versions <4.4, 'comment' must be string. A server
38+
* error will be thrown if any other type is provided.
39+
*
40+
* In server versions >=4.4, 'comment' can be any valid BSON type.
41+
*/
3542
comment?: any;
3643

3744
out?: string;

src/operations/command.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,15 @@ export interface CommandOperationOptions
4545
/** Collation */
4646
collation?: CollationOptions;
4747
maxTimeMS?: number;
48-
/** A user-provided comment to attach to this command */
49-
comment?: string | Document;
48+
/**
49+
* Comment to apply to the operation.
50+
*
51+
* In server versions <4.4, 'comment' must be string. A server
52+
* error will be thrown if any other type is provided.
53+
*
54+
* In server versions >=4.4, 'comment' can be any valid BSON type.
55+
*/
56+
comment?: any;
5057
/** Should retry failed writes */
5158
retryWrites?: boolean;
5259

src/operations/delete.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ import { Aspect, defineAspects, Hint } from './operation';
1212
export interface DeleteOptions extends CommandOperationOptions, WriteConcernOptions {
1313
/** If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. */
1414
ordered?: boolean;
15-
/** A user-provided comment to attach to this command */
16-
comment?: string | Document;
15+
/**
16+
* Comment to apply to the operation.
17+
*
18+
* In server versions <4.4, 'comment' must be string. A server
19+
* error will be thrown if any other type is provided.
20+
*
21+
* In server versions >=4.4, 'comment' can be any valid BSON type.
22+
*/
23+
comment?: any;
1724
/** Specifies the collation to use for the operation */
1825
collation?: CollationOptions;
1926
/** Specify that the update query should only consider plans using the hinted index */
@@ -43,8 +50,15 @@ export interface DeleteStatement {
4350
collation?: CollationOptions;
4451
/** A document or string that specifies the index to use to support the query predicate. */
4552
hint?: Hint;
46-
/** A user-provided comment to attach to this command */
47-
comment?: string | Document;
53+
/**
54+
* Comment to apply to the operation.
55+
*
56+
* In server versions <4.4, 'comment' must be string. A server
57+
* error will be thrown if any other type is provided.
58+
*
59+
* In server versions >=4.4, 'comment' can be any valid BSON type.
60+
*/
61+
comment?: any;
4862
}
4963

5064
/** @internal */

src/operations/find.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,15 @@ export interface FindOptions<TSchema extends Document = Document> extends Comman
4646
min?: Document;
4747
/** The exclusive upper bound for a specific index */
4848
max?: Document;
49-
/** You can put a $comment field on a query to make looking in the profiler logs simpler. */
50-
comment?: string | Document;
49+
/**
50+
* Comment to apply to the operation.
51+
*
52+
* In server versions <4.4, 'comment' must be string. A server
53+
* error will be thrown if any other type is provided.
54+
*
55+
* In server versions >=4.4, 'comment' can be any valid BSON type.
56+
*/
57+
comment?: any;
5158
/** Number of milliseconds to wait before aborting the query. */
5259
maxTimeMS?: number;
5360
/** The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. Requires `tailable` and `awaitData` to be true */

src/operations/find_and_modify.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,14 @@ interface FindAndModifyCmdBase {
8282
maxTimeMS?: number;
8383
let?: Document;
8484
writeConcern?: WriteConcern | WriteConcernSettings;
85-
86-
// TODO: add comment
85+
/**
86+
* Comment to apply to the operation.
87+
*
88+
* In server versions <4.4, 'comment' must be string. A server
89+
* error will be thrown if any other type is provided.
90+
*
91+
* In server versions >=4.4, 'comment' can be any valid BSON type.
92+
*/
8793
comment?: any;
8894
}
8995

src/operations/get_more.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ import { AbstractOperation, Aspect, defineAspects, OperationOptions } from './op
1212
export interface GetMoreOptions extends OperationOptions {
1313
/** Set the batchSize for the getMoreCommand when iterating over the query results. */
1414
batchSize?: number;
15-
/** You can put a $comment field on a query to make looking in the profiler logs simpler. */
16-
comment?: string | Document;
15+
/**
16+
* Comment to apply to the operation.
17+
*
18+
* In server versions <4.4, 'comment' must be string. A server
19+
* error will be thrown if any other type is provided.
20+
*
21+
* In server versions >=4.4, 'comment' can be any valid BSON type.
22+
*/
23+
comment?: any;
1724
/** Number of milliseconds to wait before aborting the query. */
1825
maxTimeMS?: number;
1926
}

0 commit comments

Comments
 (0)