@@ -2510,6 +2510,7 @@ type Pipe struct {
25102510 allowDisk bool
25112511 batchSize int
25122512 maxTimeMS int64
2513+ collation * Collation
25132514}
25142515
25152516type pipeCmd struct {
@@ -2519,6 +2520,7 @@ type pipeCmd struct {
25192520 Explain bool `bson:",omitempty"`
25202521 AllowDisk bool `bson:"allowDiskUse,omitempty"`
25212522 MaxTimeMS int64 `bson:"maxTimeMS,omitempty"`
2523+ Collation * Collation `bson:"collation,omitempty"`
25222524}
25232525
25242526type pipeCmdCursor struct {
@@ -2539,6 +2541,7 @@ type pipeCmdCursor struct {
25392541// http://docs.mongodb.org/manual/applications/aggregation
25402542// http://docs.mongodb.org/manual/tutorial/aggregation-examples
25412543//
2544+
25422545func (c * Collection ) Pipe (pipeline interface {}) * Pipe {
25432546 session := c .Database .Session
25442547 session .m .RLock ()
@@ -2572,6 +2575,7 @@ func (p *Pipe) Iter() *Iter {
25722575 Pipeline : p .pipeline ,
25732576 AllowDisk : p .allowDisk ,
25742577 Cursor : & pipeCmdCursor {p .batchSize },
2578+ Collation : p .collation ,
25752579 }
25762580 if p .maxTimeMS > 0 {
25772581 cmd .MaxTimeMS = p .maxTimeMS
@@ -2761,6 +2765,22 @@ func (p *Pipe) SetMaxTime(d time.Duration) *Pipe {
27612765 return p
27622766}
27632767
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+
27642784// LastError the error status of the preceding write operation on the current connection.
27652785//
27662786// Relevant documentation:
0 commit comments