Skip to content

Commit 4b2134d

Browse files
benjirewisBenjamin Rewis
authored andcommitted
GODRIVER-1775 Deprecate unnecessary FindOne options (#573)
1 parent 2524573 commit 4b2134d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

mongo/options/findoptions.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ type FindOneOptions struct {
309309
AllowPartialResults *bool
310310

311311
// The maximum number of documents to be included in each batch returned by the server.
312+
//
313+
// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
312314
BatchSize *int32
313315

314316
// Specifies a collation to use for string comparisons during the operation. This option is only valid for MongoDB
@@ -322,6 +324,8 @@ type FindOneOptions struct {
322324

323325
// Specifies the type of cursor that should be created for the operation. The default is NonTailable, which means
324326
// that the cursor will be closed by the server when the last batch of documents is retrieved.
327+
//
328+
// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
325329
CursorType *CursorType
326330

327331
// The index to use for the aggregation. This should either be the index name as a string or the index specification
@@ -336,6 +340,8 @@ type FindOneOptions struct {
336340
// The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.
337341
// This option is only valid for tailable await cursors (see the CursorType option for more information) and
338342
// MongoDB versions >= 3.2. For other cursor types or previous server versions, this option is ignored.
343+
//
344+
// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
339345
MaxAwaitTime *time.Duration
340346

341347
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
@@ -348,9 +354,14 @@ type FindOneOptions struct {
348354

349355
// If true, the cursor created by the operation will not timeout after a period of inactivity. The default value
350356
// is false.
357+
//
358+
// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
351359
NoCursorTimeout *bool
352360

353361
// This option is for internal replication use only and should not be set.
362+
//
363+
// Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by the server if it is
364+
// set.
354365
OplogReplay *bool
355366

356367
// A document describing which fields will be included in the document returned by the operation. The default value
@@ -391,6 +402,8 @@ func (f *FindOneOptions) SetAllowPartialResults(b bool) *FindOneOptions {
391402
}
392403

393404
// SetBatchSize sets the value for the BatchSize field.
405+
//
406+
// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
394407
func (f *FindOneOptions) SetBatchSize(i int32) *FindOneOptions {
395408
f.BatchSize = &i
396409
return f
@@ -409,6 +422,8 @@ func (f *FindOneOptions) SetComment(comment string) *FindOneOptions {
409422
}
410423

411424
// SetCursorType sets the value for the CursorType field.
425+
//
426+
// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
412427
func (f *FindOneOptions) SetCursorType(ct CursorType) *FindOneOptions {
413428
f.CursorType = &ct
414429
return f
@@ -427,6 +442,8 @@ func (f *FindOneOptions) SetMax(max interface{}) *FindOneOptions {
427442
}
428443

429444
// SetMaxAwaitTime sets the value for the MaxAwaitTime field.
445+
//
446+
// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
430447
func (f *FindOneOptions) SetMaxAwaitTime(d time.Duration) *FindOneOptions {
431448
f.MaxAwaitTime = &d
432449
return f
@@ -445,12 +462,17 @@ func (f *FindOneOptions) SetMin(min interface{}) *FindOneOptions {
445462
}
446463

447464
// SetNoCursorTimeout sets the value for the NoCursorTimeout field.
465+
//
466+
// Deprecated: This option is not valid for a findOne operation, as no cursor is actually created.
448467
func (f *FindOneOptions) SetNoCursorTimeout(b bool) *FindOneOptions {
449468
f.NoCursorTimeout = &b
450469
return f
451470
}
452471

453472
// SetOplogReplay sets the value for the OplogReplay field.
473+
//
474+
// Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by the server if it is
475+
// set.
454476
func (f *FindOneOptions) SetOplogReplay(b bool) *FindOneOptions {
455477
f.OplogReplay = &b
456478
return f

0 commit comments

Comments
 (0)