Skip to content

Commit cb7757f

Browse files
committed
add bulkWrite
1 parent dbb9b06 commit cb7757f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

x/mongo/driver/xoptions/options.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@ func SetInternalAggregateOptions(a *options.AggregateOptionsBuilder, key string,
6565
return nil
6666
}
6767

68+
// SetInternalBulkWriteOptions sets internal options for BulkWriteOptions.
69+
func SetInternalBulkWriteOptions(a *options.BulkWriteOptionsBuilder, key string, option any) error {
70+
typeErrFunc := func(t string) error {
71+
return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t)
72+
}
73+
switch key {
74+
case "rawData":
75+
b, ok := option.(bool)
76+
if !ok {
77+
return typeErrFunc("bool")
78+
}
79+
a.Opts = append(a.Opts, func(opts *options.BulkWriteOptions) error {
80+
opts.Internal = optionsutil.WithValue(opts.Internal, key, b)
81+
return nil
82+
})
83+
default:
84+
return fmt.Errorf("unsupported option: %q", key)
85+
}
86+
return nil
87+
}
88+
6889
// SetInternalCountOptions sets internal options for CountOptions.
6990
func SetInternalCountOptions(a *options.CountOptionsBuilder, key string, option any) error {
7091
typeErrFunc := func(t string) error {

0 commit comments

Comments
 (0)