forked from mongodb/mongo-go-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
685 lines (566 loc) · 21.9 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
// Copyright (C) MongoDB, Inc. 2017-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
package options
import (
"time"
"github.com/mongodb/mongo-go-driver/bson"
)
// Optioner is the interface implemented by types that can be used as options
// to a command.
type Optioner interface {
Option(*bson.Document)
}
// FindOptioner is the interface implemented by types that can be used as
// Options for Find commands.
type FindOptioner interface {
Optioner
findOption()
}
// FindOneOptioner is the interface implemented by types that can be used as
// Options for FindOne operations.
type FindOneOptioner interface {
Optioner
findOneOption()
}
// CountOptioner is the interface implemented by types that can be used as
// Options for Count commands.
type CountOptioner interface {
Optioner
countOption()
}
// DeleteOptioner is the interface implemented by types that can be used as
// Options for Delete commands.
type DeleteOptioner interface {
Optioner
deleteOption()
}
// UpdateOptioner is the interface implemented by types that can be used as
// Options for Update commands.
type UpdateOptioner interface {
Optioner
updateOption()
}
// ReplaceOptioner is the interface implemented by types that can be used as
// Options for Update commands.
type ReplaceOptioner interface {
UpdateOptioner
replaceOption()
}
// DistinctOptioner is the interface implemented by types that can be used as
// Options for Distinct commands.
type DistinctOptioner interface {
Optioner
distinctOption()
}
// AggregateOptioner is the interface implemented by types that can be used
// as Options for an Aggregate command.
type AggregateOptioner interface {
Optioner
aggregateOption()
}
// InsertOptioner is the interface implemented by types that can be used as
// Options for insert commands.
type InsertOptioner interface {
Optioner
insertOption()
}
// InsertOneOptioner is the interface implemented by types that can be used as
// Options for InsertOne commands.
type InsertOneOptioner interface {
InsertOptioner
insertOneOption()
}
// InsertManyOptioner is the interface implemented by types that can be used as
// Options for InsertMany commands.
type InsertManyOptioner interface {
InsertOptioner
insertManyOption()
}
// FindOneAndDeleteOptioner is the interface implemented by types that can be
// used as Options for FindOneAndDelete commands.
type FindOneAndDeleteOptioner interface {
Optioner
findOneAndDeleteOption()
}
// FindOneAndUpdateOptioner is the interface implemented by types that can be
// used as Options for FindOneAndUpdate commands.
type FindOneAndUpdateOptioner interface {
Optioner
findOneAndUpdateOption()
}
// FindOneAndReplaceOptioner is the interface implemented by types that can be
// used as Options for FindOneAndReplace commands.
type FindOneAndReplaceOptioner interface {
Optioner
findOneAndReplaceOption()
}
// ChangeStreamOptioner is the interface implemented by types that can be used as Options for
// change stream operations.
type ChangeStreamOptioner interface {
Optioner
changeStreamOption()
}
// ListCollectionsOptioner is the interface implemented by types that can be used as
// Options for ListCollections operations.
type ListCollectionsOptioner interface {
Optioner
listCollectionsOption()
}
// ListDatabasesOptioner is the interface implemented by types that can be used as
// Options for ListDatabase operations.
type ListDatabasesOptioner interface {
Optioner
listDatabasesOption()
}
// ListIndexesOptioner is the interface implemented by types that can be used as
// Options for ListIndexes operations.
type ListIndexesOptioner interface {
Optioner
listIndexesOption()
}
// CursorOptioner is the interface implemented by types that can be used as
// Options for Cursor operations.
type CursorOptioner interface {
Optioner
cursorOption()
}
var (
_ AggregateOptioner = (*OptAllowDiskUse)(nil)
_ AggregateOptioner = (*OptBatchSize)(nil)
_ AggregateOptioner = (*OptBypassDocumentValidation)(nil)
_ AggregateOptioner = (*OptCollation)(nil)
_ AggregateOptioner = (*OptComment)(nil)
_ AggregateOptioner = (*OptMaxTime)(nil)
_ AggregateOptioner = (*OptReadConcern)(nil)
_ AggregateOptioner = (*OptWriteConcern)(nil)
_ CountOptioner = (*OptCollation)(nil)
_ CountOptioner = (*OptHint)(nil)
_ CountOptioner = (*OptLimit)(nil)
_ CountOptioner = (*OptMaxTime)(nil)
_ CountOptioner = (*OptReadConcern)(nil)
_ CountOptioner = (*OptSkip)(nil)
_ CursorOptioner = OptBatchSize(0)
_ DeleteOptioner = (*OptCollation)(nil)
_ DeleteOptioner = (*OptWriteConcern)(nil)
_ DistinctOptioner = (*OptCollation)(nil)
_ DistinctOptioner = (*OptMaxTime)(nil)
_ DistinctOptioner = (*OptReadConcern)(nil)
_ FindOneAndDeleteOptioner = (*OptCollation)(nil)
_ FindOneAndDeleteOptioner = (*OptMaxTime)(nil)
_ FindOneAndDeleteOptioner = (*OptProjection)(nil)
_ FindOneAndDeleteOptioner = (*OptSort)(nil)
_ FindOneAndDeleteOptioner = (*OptWriteConcern)(nil)
_ FindOneAndReplaceOptioner = (*OptBypassDocumentValidation)(nil)
_ FindOneAndReplaceOptioner = (*OptCollation)(nil)
_ FindOneAndReplaceOptioner = (*OptMaxTime)(nil)
_ FindOneAndReplaceOptioner = (*OptProjection)(nil)
_ FindOneAndReplaceOptioner = (*OptReturnDocument)(nil)
_ FindOneAndReplaceOptioner = (*OptSort)(nil)
_ FindOneAndReplaceOptioner = (*OptUpsert)(nil)
_ FindOneAndReplaceOptioner = (*OptWriteConcern)(nil)
_ FindOneAndUpdateOptioner = (*OptArrayFilters)(nil)
_ FindOneAndUpdateOptioner = (*OptBypassDocumentValidation)(nil)
_ FindOneAndUpdateOptioner = (*OptCollation)(nil)
_ FindOneAndUpdateOptioner = (*OptMaxTime)(nil)
_ FindOneAndUpdateOptioner = (*OptProjection)(nil)
_ FindOneAndUpdateOptioner = (*OptReturnDocument)(nil)
_ FindOneAndUpdateOptioner = (*OptSort)(nil)
_ FindOneAndUpdateOptioner = (*OptUpsert)(nil)
_ FindOneAndUpdateOptioner = (*OptWriteConcern)(nil)
_ FindOptioner = (*OptAllowPartialResults)(nil)
_ FindOptioner = (*OptBatchSize)(nil)
_ FindOptioner = (*OptCollation)(nil)
_ FindOptioner = OptCursorType(0)
_ FindOptioner = (*OptComment)(nil)
_ FindOptioner = (*OptHint)(nil)
_ FindOptioner = (*OptLimit)(nil)
_ FindOptioner = (*OptMaxAwaitTime)(nil)
_ FindOptioner = (*OptMaxScan)(nil)
_ FindOptioner = (*OptMaxTime)(nil)
_ FindOptioner = (*OptMin)(nil)
_ FindOptioner = (*OptNoCursorTimeout)(nil)
_ FindOptioner = (*OptOplogReplay)(nil)
_ FindOptioner = (*OptProjection)(nil)
_ FindOptioner = (*OptReadConcern)(nil)
_ FindOptioner = (*OptReturnKey)(nil)
_ FindOptioner = (*OptShowRecordID)(nil)
_ FindOptioner = (*OptSkip)(nil)
_ FindOptioner = (*OptSnapshot)(nil)
_ FindOptioner = (*OptSort)(nil)
_ FindOneOptioner = (*OptAllowPartialResults)(nil)
_ FindOneOptioner = (*OptBatchSize)(nil)
_ FindOneOptioner = (*OptCollation)(nil)
_ FindOneOptioner = OptCursorType(0)
_ FindOneOptioner = (*OptComment)(nil)
_ FindOneOptioner = (*OptHint)(nil)
_ FindOneOptioner = (*OptMaxAwaitTime)(nil)
_ FindOneOptioner = (*OptMaxScan)(nil)
_ FindOneOptioner = (*OptMaxTime)(nil)
_ FindOneOptioner = (*OptMin)(nil)
_ FindOneOptioner = (*OptNoCursorTimeout)(nil)
_ FindOneOptioner = (*OptOplogReplay)(nil)
_ FindOneOptioner = (*OptProjection)(nil)
_ FindOneOptioner = (*OptReadConcern)(nil)
_ FindOneOptioner = (*OptReturnKey)(nil)
_ FindOneOptioner = (*OptShowRecordID)(nil)
_ FindOneOptioner = (*OptSkip)(nil)
_ FindOneOptioner = (*OptSnapshot)(nil)
_ FindOneOptioner = (*OptSort)(nil)
_ InsertManyOptioner = (*OptBypassDocumentValidation)(nil)
_ InsertManyOptioner = (*OptOrdered)(nil)
_ InsertManyOptioner = (*OptWriteConcern)(nil)
_ InsertOneOptioner = (*OptBypassDocumentValidation)(nil)
_ InsertOneOptioner = (*OptWriteConcern)(nil)
_ InsertOptioner = (*OptBypassDocumentValidation)(nil)
_ InsertOptioner = (*OptOrdered)(nil)
_ InsertOptioner = (*OptWriteConcern)(nil)
_ ListDatabasesOptioner = OptNameOnly(false)
_ ListIndexesOptioner = OptBatchSize(0)
_ ReplaceOptioner = (*OptBypassDocumentValidation)(nil)
_ ReplaceOptioner = (*OptCollation)(nil)
_ ReplaceOptioner = (*OptUpsert)(nil)
_ ReplaceOptioner = (*OptWriteConcern)(nil)
_ UpdateOptioner = (*OptUpsert)(nil)
_ UpdateOptioner = (*OptArrayFilters)(nil)
_ UpdateOptioner = (*OptBypassDocumentValidation)(nil)
_ UpdateOptioner = (*OptCollation)(nil)
_ UpdateOptioner = (*OptWriteConcern)(nil)
_ ChangeStreamOptioner = (*OptBatchSize)(nil)
_ ChangeStreamOptioner = (*OptCollation)(nil)
_ ChangeStreamOptioner = (*OptFullDocument)(nil)
_ ChangeStreamOptioner = (*OptMaxAwaitTime)(nil)
_ ChangeStreamOptioner = (*OptReadConcern)(nil)
_ ChangeStreamOptioner = (*OptResumeAfter)(nil)
)
// OptAllowDiskUse is for internal use.
type OptAllowDiskUse bool
// Option implements the Optioner interface.
func (opt OptAllowDiskUse) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("allowDiskUse", bool(opt)))
}
func (opt OptAllowDiskUse) aggregateOption() {}
// OptAllowPartialResults is for internal use.
type OptAllowPartialResults bool
// Option implements the Optioner interface.
func (opt OptAllowPartialResults) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("allowPartialResults", bool(opt)))
}
func (opt OptAllowPartialResults) findOption() {}
func (opt OptAllowPartialResults) findOneOption() {}
// OptArrayFilters is for internal use.
type OptArrayFilters []*bson.Document
// Option implements the Optioner interface.
func (opt OptArrayFilters) Option(d *bson.Document) {
arr := bson.NewArray()
for _, af := range opt {
arr.Append(bson.VC.Document(af))
}
d.Append(bson.EC.Array("arrayFilters", arr))
}
func (OptArrayFilters) findOneAndUpdateOption() {}
func (OptArrayFilters) updateOption() {}
// OptBatchSize is for internal use.
type OptBatchSize int32
// Option implements the Optioner interface.
func (opt OptBatchSize) Option(d *bson.Document) {
d.Append(bson.EC.Int32("batchSize", int32(opt)))
}
func (OptBatchSize) aggregateOption() {}
func (OptBatchSize) changeStreamOption() {}
func (OptBatchSize) findOption() {}
func (OptBatchSize) findOneOption() {}
func (OptBatchSize) listIndexesOption() {}
func (OptBatchSize) cursorOption() {}
// OptBypassDocumentValidation is for internal use.
type OptBypassDocumentValidation bool
// Option implements the Optioner interface.
func (opt OptBypassDocumentValidation) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("bypassDocumentValidation", bool(opt)))
}
func (OptBypassDocumentValidation) aggregateOption() {}
func (OptBypassDocumentValidation) findOneAndReplaceOption() {}
func (OptBypassDocumentValidation) findOneAndUpdateOption() {}
func (OptBypassDocumentValidation) insertManyOption() {}
func (OptBypassDocumentValidation) insertOption() {}
func (OptBypassDocumentValidation) insertOneOption() {}
func (OptBypassDocumentValidation) replaceOption() {}
func (OptBypassDocumentValidation) updateOption() {}
// OptCollation is for internal use.
type OptCollation struct{ Collation *Collation }
// Option implements the Optioner interface.
func (opt OptCollation) Option(d *bson.Document) {
d.Append(bson.EC.SubDocument("collation", opt.Collation.toDocument()))
}
func (OptCollation) aggregateOption() {}
func (OptCollation) changeStreamOption() {}
func (OptCollation) countOption() {}
func (OptCollation) deleteOption() {}
func (OptCollation) distinctOption() {}
func (OptCollation) findOption() {}
func (OptCollation) findOneOption() {}
func (OptCollation) findOneAndDeleteOption() {}
func (OptCollation) findOneAndReplaceOption() {}
func (OptCollation) findOneAndUpdateOption() {}
func (OptCollation) replaceOption() {}
func (OptCollation) updateOption() {}
// OptComment is for internal use.
type OptComment string
// Option implements the Optioner interface.
func (opt OptComment) Option(d *bson.Document) {
d.Append(bson.EC.String("comment", string(opt)))
}
func (OptComment) aggregateOption() {}
func (OptComment) findOption() {}
func (OptComment) findOneOption() {}
// OptCursorType is for internal use.
type OptCursorType CursorType
// Option implements the Optioner interface.
func (opt OptCursorType) Option(d *bson.Document) {
switch CursorType(opt) {
case Tailable:
d.Append(bson.EC.Boolean("tailable", true))
case TailableAwait:
d.Append(bson.EC.Boolean("tailable", true), bson.EC.Boolean("awaitData", true))
}
}
func (OptCursorType) findOption() {}
func (OptCursorType) findOneOption() {}
// OptFullDocument is for internal use.
type OptFullDocument string
// Option implements the Optioner interface.
func (opt OptFullDocument) Option(d *bson.Document) {
d.Append(bson.EC.String("fullDocument", string(opt)))
}
func (OptFullDocument) changeStreamOption() {}
// OptHint is for internal use.
type OptHint struct{ Hint interface{} }
// Option implements the Optioner interface.
func (opt OptHint) Option(d *bson.Document) {
switch t := (opt).Hint.(type) {
case string:
d.Append(bson.EC.String("hint", t))
case *bson.Document:
d.Append(bson.EC.SubDocument("hint", t))
}
}
func (OptHint) countOption() {}
func (OptHint) findOption() {}
func (OptHint) findOneOption() {}
// OptLimit is for internal use.
type OptLimit int64
// Option implements the Optioner interface.
func (opt OptLimit) Option(d *bson.Document) {
d.Append(bson.EC.Int64("limit", int64(opt)))
}
func (OptLimit) countOption() {}
func (OptLimit) findOption() {}
// OptMax is for internal use.
type OptMax struct{ Max *bson.Document }
// Option implements the Optioner interface.
func (opt OptMax) Option(d *bson.Document) {
d.Append(bson.EC.SubDocument("max", opt.Max))
}
func (OptMax) findOption() {}
func (OptMax) findOneOption() {}
// OptMaxAwaitTime is for internal use.
type OptMaxAwaitTime time.Duration
// Option implements the Optioner interface.
func (opt OptMaxAwaitTime) Option(d *bson.Document) {
d.Append(bson.EC.Int64("maxAwaitTimeMS", int64(time.Duration(opt)/time.Millisecond)))
}
func (OptMaxAwaitTime) changeStreamOption() {}
func (OptMaxAwaitTime) findOption() {}
func (OptMaxAwaitTime) findOneOption() {}
// OptMaxScan is for internal use.
type OptMaxScan int64
// Option implements the Optioner interface.
func (opt OptMaxScan) Option(d *bson.Document) {
d.Append(bson.EC.Int64("maxScan", int64(opt)))
}
func (OptMaxScan) findOption() {}
func (OptMaxScan) findOneOption() {}
// OptMaxTime is for internal use.
type OptMaxTime time.Duration
// Option implements the Optioner interface.
func (opt OptMaxTime) Option(d *bson.Document) {
d.Append(bson.EC.Int64("maxTimeMS", int64(time.Duration(opt)/time.Millisecond)))
}
func (OptMaxTime) aggregateOption() {}
func (OptMaxTime) countOption() {}
func (OptMaxTime) distinctOption() {}
func (OptMaxTime) findOption() {}
func (OptMaxTime) findOneOption() {}
func (OptMaxTime) findOneAndDeleteOption() {}
func (OptMaxTime) findOneAndReplaceOption() {}
func (OptMaxTime) findOneAndUpdateOption() {}
// OptMin is for internal use.
type OptMin struct{ Min *bson.Document }
// Option implements the Optioner interface.
func (opt OptMin) Option(d *bson.Document) {
d.Append(bson.EC.SubDocument("min", opt.Min))
}
func (OptMin) findOption() {}
func (OptMin) findOneOption() {}
// OptNoCursorTimeout is for internal use.
type OptNoCursorTimeout bool
// Option implements the Optioner interface.
func (opt OptNoCursorTimeout) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("noCursorTimeout", bool(opt)))
}
func (OptNoCursorTimeout) findOption() {}
func (OptNoCursorTimeout) findOneOption() {}
// OptOplogReplay is for internal use.
type OptOplogReplay bool
// Option implements the Optioner interface.
func (opt OptOplogReplay) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("oplogReplay", bool(opt)))
}
func (OptOplogReplay) findOption() {}
func (OptOplogReplay) findOneOption() {}
// OptOrdered is for internal use.
type OptOrdered bool
// Option implements the Optioner interface.
func (opt OptOrdered) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("ordered", bool(opt)))
}
func (OptOrdered) insertManyOption() {}
func (OptOrdered) insertOption() {}
// OptProjection is for internal use.
type OptProjection struct {
Projection *bson.Document
find bool
}
// Option implements the Optioner interface.
func (opt OptProjection) Option(d *bson.Document) {
var key = "fields"
if opt.find {
key = "projection"
}
d.Append(bson.EC.SubDocument(key, opt.Projection))
}
// IsFind is for internal use.
func (opt OptProjection) IsFind() OptProjection {
opt.find = true
return opt
}
func (OptProjection) findOption() {}
func (OptProjection) findOneOption() {}
func (OptProjection) findOneAndDeleteOption() {}
func (OptProjection) findOneAndReplaceOption() {}
func (OptProjection) findOneAndUpdateOption() {}
// OptReadConcern is for internal use.
type OptReadConcern struct{ ReadConcern *bson.Element }
// Option implements the Optioner interface.
func (opt OptReadConcern) Option(d *bson.Document) {
if _, err := d.Lookup(opt.ReadConcern.Key()); err == bson.ErrElementNotFound {
d.Append(opt.ReadConcern)
}
}
func (OptReadConcern) aggregateOption() {}
func (OptReadConcern) changeStreamOption() {}
func (OptReadConcern) countOption() {}
func (OptReadConcern) distinctOption() {}
func (OptReadConcern) findOption() {}
func (OptReadConcern) findOneOption() {}
// OptResumeAfter is for internal use.
type OptResumeAfter struct{ ResumeAfter *bson.Document }
// Option implements the Optioner interface.
func (opt OptResumeAfter) Option(d *bson.Document) {
if opt.ResumeAfter != nil {
d.Append(bson.EC.SubDocument("resumeAfter", opt.ResumeAfter))
}
}
func (OptResumeAfter) changeStreamOption() {}
// OptReturnDocument is for internal use.
type OptReturnDocument ReturnDocument
// Option implements the Optioner interface.
func (opt OptReturnDocument) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("new", ReturnDocument(opt) == After))
}
func (OptReturnDocument) findOneAndReplaceOption() {}
func (OptReturnDocument) findOneAndUpdateOption() {}
// OptReturnKey is for internal use.
type OptReturnKey bool
// Option implements the Optioner interface.
func (opt OptReturnKey) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("returnKey", bool(opt)))
}
func (OptReturnKey) findOption() {}
func (OptReturnKey) findOneOption() {}
// OptShowRecordID is for internal use.
type OptShowRecordID bool
// Option implements the Optioner interface.
func (opt OptShowRecordID) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("showRecordId", bool(opt)))
}
func (OptShowRecordID) findOption() {}
func (OptShowRecordID) findOneOption() {}
// OptSkip is for internal use.
type OptSkip int64
// Option implements the Optioner interface.
func (opt OptSkip) Option(d *bson.Document) {
d.Append(bson.EC.Int64("skip", int64(opt)))
}
func (OptSkip) countOption() {}
func (OptSkip) findOption() {}
func (OptSkip) findOneOption() {}
// OptSnapshot is for internal use.
type OptSnapshot bool
// Option implements the Optioner interface.
func (opt OptSnapshot) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("snapshot", bool(opt)))
}
func (OptSnapshot) findOption() {}
func (OptSnapshot) findOneOption() {}
// OptSort is for internal use.
type OptSort struct{ Sort *bson.Document }
// Option implements the Optioner interface.
func (opt OptSort) Option(d *bson.Document) {
d.Append(bson.EC.SubDocument("sort", opt.Sort))
}
func (OptSort) findOption() {}
func (OptSort) findOneOption() {}
func (OptSort) findOneAndDeleteOption() {}
func (OptSort) findOneAndReplaceOption() {}
func (OptSort) findOneAndUpdateOption() {}
// OptUpsert is for internal use.
type OptUpsert bool
// Option implements the Optioner interface.
func (opt OptUpsert) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("upsert", bool(opt)))
}
func (OptUpsert) findOneAndReplaceOption() {}
func (OptUpsert) findOneAndUpdateOption() {}
func (OptUpsert) replaceOption() {}
func (OptUpsert) updateOption() {}
// OptWriteConcern is for internal use.
type OptWriteConcern struct {
WriteConcern *bson.Element
Acknowledged bool
}
// Option implements the Optioner interface.
func (opt OptWriteConcern) Option(d *bson.Document) {
if _, err := d.Lookup(opt.WriteConcern.Key()); err == bson.ErrElementNotFound {
d.Append(opt.WriteConcern)
}
}
func (OptWriteConcern) aggregateOption() {}
func (OptWriteConcern) deleteOption() {}
func (OptWriteConcern) findOneAndUpdateOption() {}
func (OptWriteConcern) findOneAndReplaceOption() {}
func (OptWriteConcern) findOneAndDeleteOption() {}
func (OptWriteConcern) insertOption() {}
func (OptWriteConcern) insertManyOption() {}
func (OptWriteConcern) insertOneOption() {}
func (OptWriteConcern) replaceOption() {}
func (OptWriteConcern) updateOption() {}
// OptNameOnly is for internal use.
type OptNameOnly bool
// Option implements the Optioner interface.
func (opt OptNameOnly) Option(d *bson.Document) {
d.Append(bson.EC.Boolean("nameOnly", bool(opt)))
}
func (OptNameOnly) listDatabasesOption() {}