Skip to content

Commit

Permalink
docs: add docstring comments to 'comment' option
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Mar 14, 2022
1 parent 20c9681 commit 2847892
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 16 deletions.
10 changes: 8 additions & 2 deletions src/change_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,14 @@ export interface ChangeStreamCursorOptions extends AbstractCursorOptions {
startAtOperationTime?: OperationTime;
resumeAfter?: ResumeToken;
startAfter?: boolean;

/** todo: add comment */
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
}

Expand Down
10 changes: 9 additions & 1 deletion src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,15 @@ export interface GetMoreOptions extends CommandOptions {
batchSize?: number;
maxTimeMS?: number;
maxAwaitTimeMS?: number;
comment?: Document | string;
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
}

/** @public */
Expand Down
8 changes: 8 additions & 0 deletions src/cursor/abstract_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ export interface AbstractCursorOptions extends BSONSerializeOptions {
readConcern?: ReadConcernLike;
batchSize?: number;
maxTimeMS?: number;
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
tailable?: boolean;
awaitData?: boolean;
Expand Down
9 changes: 8 additions & 1 deletion src/operations/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ export interface AggregateOptions extends CommandOperationOptions {
hint?: Hint;
/** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */
let?: Document;
/** Comment to apply to the operation. */
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;

out?: string;
Expand Down
11 changes: 9 additions & 2 deletions src/operations/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ export interface CommandOperationOptions
/** Collation */
collation?: CollationOptions;
maxTimeMS?: number;
/** A user-provided comment to attach to this command */
comment?: string | Document;
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
/** Should retry failed writes */
retryWrites?: boolean;

Expand Down
22 changes: 18 additions & 4 deletions src/operations/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ import { Aspect, defineAspects, Hint } from './operation';
export interface DeleteOptions extends CommandOperationOptions, WriteConcernOptions {
/** If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. */
ordered?: boolean;
/** A user-provided comment to attach to this command */
comment?: string | Document;
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
/** Specifies the collation to use for the operation */
collation?: CollationOptions;
/** Specify that the update query should only consider plans using the hinted index */
Expand Down Expand Up @@ -43,8 +50,15 @@ export interface DeleteStatement {
collation?: CollationOptions;
/** A document or string that specifies the index to use to support the query predicate. */
hint?: Hint;
/** A user-provided comment to attach to this command */
comment?: string | Document;
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
}

/** @internal */
Expand Down
11 changes: 9 additions & 2 deletions src/operations/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ export interface FindOptions<TSchema extends Document = Document> extends Comman
min?: Document;
/** The exclusive upper bound for a specific index */
max?: Document;
/** You can put a $comment field on a query to make looking in the profiler logs simpler. */
comment?: string | Document;
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
/** Number of milliseconds to wait before aborting the query. */
maxTimeMS?: number;
/** 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 */
Expand Down
10 changes: 8 additions & 2 deletions src/operations/find_and_modify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ interface FindAndModifyCmdBase {
maxTimeMS?: number;
let?: Document;
writeConcern?: WriteConcern | WriteConcernSettings;

// TODO: add comment
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
}

Expand Down
11 changes: 9 additions & 2 deletions src/operations/get_more.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ import { AbstractOperation, Aspect, defineAspects, OperationOptions } from './op
export interface GetMoreOptions extends OperationOptions {
/** Set the batchSize for the getMoreCommand when iterating over the query results. */
batchSize?: number;
/** You can put a $comment field on a query to make looking in the profiler logs simpler. */
comment?: string | Document;
/**
* Comment to apply to the operation.
*
* In server versions <4.4, 'comment' must be string. A server
* error will be thrown if any other type is provided.
*
* In server versions >=4.4, 'comment' can be any valid BSON type.
*/
comment?: any;
/** Number of milliseconds to wait before aborting the query. */
maxTimeMS?: number;
}
Expand Down

0 comments on commit 2847892

Please sign in to comment.