@@ -2510,6 +2510,7 @@ type Pipe struct {
2510
2510
allowDisk bool
2511
2511
batchSize int
2512
2512
maxTimeMS int64
2513
+ collation * Collation
2513
2514
}
2514
2515
2515
2516
type pipeCmd struct {
@@ -2519,6 +2520,7 @@ type pipeCmd struct {
2519
2520
Explain bool `bson:",omitempty"`
2520
2521
AllowDisk bool `bson:"allowDiskUse,omitempty"`
2521
2522
MaxTimeMS int64 `bson:"maxTimeMS,omitempty"`
2523
+ Collation * Collation `bson:"collation,omitempty"`
2522
2524
}
2523
2525
2524
2526
type pipeCmdCursor struct {
@@ -2539,6 +2541,7 @@ type pipeCmdCursor struct {
2539
2541
// http://docs.mongodb.org/manual/applications/aggregation
2540
2542
// http://docs.mongodb.org/manual/tutorial/aggregation-examples
2541
2543
//
2544
+
2542
2545
func (c * Collection ) Pipe (pipeline interface {}) * Pipe {
2543
2546
session := c .Database .Session
2544
2547
session .m .RLock ()
@@ -2572,6 +2575,7 @@ func (p *Pipe) Iter() *Iter {
2572
2575
Pipeline : p .pipeline ,
2573
2576
AllowDisk : p .allowDisk ,
2574
2577
Cursor : & pipeCmdCursor {p .batchSize },
2578
+ Collation : p .collation ,
2575
2579
}
2576
2580
if p .maxTimeMS > 0 {
2577
2581
cmd .MaxTimeMS = p .maxTimeMS
@@ -2761,6 +2765,22 @@ func (p *Pipe) SetMaxTime(d time.Duration) *Pipe {
2761
2765
return p
2762
2766
}
2763
2767
2768
+ // Collation allows to specify language-specific rules for string comparison,
2769
+ // such as rules for lettercase and accent marks.
2770
+ // When specifying collation, the locale field is mandatory; all other collation
2771
+ // fields are optional
2772
+ //
2773
+ // Relevant documentation:
2774
+ //
2775
+ // https://docs.mongodb.com/manual/reference/collation/
2776
+ //
2777
+ func (p * Pipe ) Collation (collation * Collation ) * Pipe {
2778
+ if collation != nil {
2779
+ p .collation = collation
2780
+ }
2781
+ return p
2782
+ }
2783
+
2764
2784
// LastError the error status of the preceding write operation on the current connection.
2765
2785
//
2766
2786
// Relevant documentation:
0 commit comments