Skip to content

Commit f420860

Browse files
committed
add client bulkWrite
1 parent b430a2e commit f420860

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

internal/integration/unified/client_operation_execution.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ func executeClientBulkWrite(ctx context.Context, operation *operation) (*operati
235235
return nil, err
236236
}
237237
opts.SetWriteConcern(c)
238+
case "rawData":
239+
opts.SetRawData(val.Boolean())
238240
default:
239241
return nil, fmt.Errorf("unrecognized bulkWrite option %q", key)
240242
}

mongo/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ func (c *Client) BulkWrite(ctx context.Context, writes []ClientBulkWrite,
956956
client: c,
957957
selector: selector,
958958
writeConcern: wc,
959+
rawData: bwo.RawData,
959960
}
960961
if bwo.VerboseResults == nil || !(*bwo.VerboseResults) {
961962
op.errorsOnly = true

mongo/client_bulk_write.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type clientBulkWrite struct {
4444
client *Client
4545
selector description.ServerSelector
4646
writeConcern *writeconcern.WriteConcern
47+
rawData *bool
4748

4849
result ClientBulkWriteResult
4950
}
@@ -143,6 +144,10 @@ func (bw *clientBulkWrite) newCommand() func([]byte, description.SelectedServer)
143144
}
144145
dst = bsoncore.AppendDocumentElement(dst, "let", let)
145146
}
147+
// Set rawData for 8.2+ servers.
148+
if bw.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) {
149+
dst = bsoncore.AppendBooleanElement(dst, "rawData", *bw.rawData)
150+
}
146151
return dst, nil
147152
}
148153
}

mongo/options/clientbulkwriteoptions.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type ClientBulkWriteOptions struct {
1919
Ordered *bool
2020
Let interface{}
2121
WriteConcern *writeconcern.WriteConcern
22+
RawData *bool
2223
VerboseResults *bool
2324
}
2425

@@ -108,6 +109,18 @@ func (b *ClientBulkWriteOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteCo
108109
return b
109110
}
110111

112+
// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
113+
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
114+
func (b *ClientBulkWriteOptionsBuilder) SetRawData(rawData bool) *ClientBulkWriteOptionsBuilder {
115+
b.Opts = append(b.Opts, func(opts *ClientBulkWriteOptions) error {
116+
opts.RawData = &rawData
117+
118+
return nil
119+
})
120+
121+
return b
122+
}
123+
111124
// SetVerboseResults sets the value for the VerboseResults field. Specifies whether detailed
112125
// results for each successful operation should be included in the returned BulkWriteResult.
113126
// The defaults value is false.

0 commit comments

Comments
 (0)