Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/integration/unified/collection_operation_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func executeBulkWrite(ctx context.Context, operation *operation) (*operationResu
}
case "let":
opts.SetLet(val.Document())
case "rawData":
opts.SetRawData(val.Boolean())
default:
return nil, fmt.Errorf("unrecognized bulkWrite option %q", key)
}
Expand Down Expand Up @@ -854,6 +856,8 @@ func executeFindOneAndDelete(ctx context.Context, operation *operation) (*operat
opts.SetSort(val.Document())
case "let":
opts.SetLet(val.Document())
case "rawData":
opts.SetRawData(val.Boolean())
default:
return nil, fmt.Errorf("unrecognized findOneAndDelete option %q", key)
}
Expand Down Expand Up @@ -936,6 +940,8 @@ func executeFindOneAndReplace(ctx context.Context, operation *operation) (*opera
opts.SetSort(val.Document())
case "upsert":
opts.SetUpsert(val.Boolean())
case "rawData":
opts.SetRawData(val.Boolean())
default:
return nil, fmt.Errorf("unrecognized findOneAndReplace option %q", key)
}
Expand Down Expand Up @@ -1028,6 +1034,8 @@ func executeFindOneAndUpdate(ctx context.Context, operation *operation) (*operat
}
case "upsert":
opts.SetUpsert(val.Boolean())
case "rawData":
opts.SetRawData(val.Boolean())
default:
return nil, fmt.Errorf("unrecognized findOneAndUpdate option %q", key)
}
Expand Down Expand Up @@ -1318,6 +1326,8 @@ func executeReplaceOne(ctx context.Context, operation *operation) (*operationRes
opts.SetUpsert(val.Boolean())
case "let":
opts.SetLet(val.Document())
case "rawData":
opts.SetRawData(val.Boolean())
default:
return nil, fmt.Errorf("unrecognized replaceOne option %q", key)
}
Expand Down Expand Up @@ -1516,6 +1526,8 @@ func createFindCursor(ctx context.Context, operation *operation) (*cursorResult,
case "maxAwaitTimeMS":
maxAwaitTimeMS := time.Duration(val.Int32()) * time.Millisecond
opts.SetMaxAwaitTime(maxAwaitTimeMS)
case "rawData":
opts.SetRawData(val.Boolean())
default:
return nil, fmt.Errorf("unrecognized find option %q", key)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/integration/unified/crud_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func createUpdateManyArguments(args bson.Raw) (*updateArguments, *options.Update
}
case "upsert":
opts.SetUpsert(val.Boolean())
case "rawData":
opts.SetRawData(val.Boolean())
default:
return nil, nil, fmt.Errorf("unrecognized update option %q", key)
}
Expand Down Expand Up @@ -125,6 +127,8 @@ func createUpdateOneArguments(args bson.Raw) (*updateArguments, *options.UpdateO
opts.SetUpsert(val.Boolean())
case "sort":
opts.SetSort(val.Document())
case "rawData":
opts.SetRawData(val.Boolean())
default:
return nil, nil, fmt.Errorf("unrecognized update option %q", key)
}
Expand Down
13 changes: 13 additions & 0 deletions mongo/bulk_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type bulkWrite struct {
writeConcern *writeconcern.WriteConcern
result BulkWriteResult
let interface{}
rawData *bool
}

func (bw *bulkWrite) execute(ctx context.Context) error {
Expand Down Expand Up @@ -209,6 +210,10 @@ func (bw *bulkWrite) runInsert(ctx context.Context, batch bulkWriteBatch) (opera
}
op = op.Retry(retry)

if bw.rawData != nil {
op.RawData(*bw.rawData)
}

err := op.Execute(ctx)

return op.Result(), err
Expand Down Expand Up @@ -282,6 +287,10 @@ func (bw *bulkWrite) runDelete(ctx context.Context, batch bulkWriteBatch) (opera
}
op = op.Retry(retry)

if bw.rawData != nil {
op.RawData(*bw.rawData)
}

err := op.Execute(ctx)

return op.Result(), err
Expand Down Expand Up @@ -415,6 +424,10 @@ func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (opera
}
op = op.Retry(retry)

if bw.rawData != nil {
op.RawData(*bw.rawData)
}

err := op.Execute(ctx)

return op.Result(), err
Expand Down
19 changes: 19 additions & 0 deletions mongo/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func (coll *Collection) BulkWrite(ctx context.Context, models []WriteModel,
selector: selector,
writeConcern: wc,
let: args.Let,
rawData: args.RawData,
}

err = op.execute(ctx)
Expand Down Expand Up @@ -691,6 +692,9 @@ func (coll *Collection) updateOrReplace(
}
op = op.Comment(comment)
}
if args.RawData != nil {
op = op.RawData(*args.RawData)
}
retry := driver.RetryNone
// retryable writes are only enabled updateOne/replaceOne operations
if !multi && coll.client.retryWrites {
Expand Down Expand Up @@ -785,6 +789,7 @@ func (coll *Collection) UpdateOne(
Hint: args.Hint,
Upsert: args.Upsert,
Let: args.Let,
RawData: args.RawData,
}

return coll.updateOrReplace(ctx, f, update, false, rrOne, true, args.Sort, updateOptions)
Expand Down Expand Up @@ -875,6 +880,7 @@ func (coll *Collection) ReplaceOne(
Hint: args.Hint,
Let: args.Let,
Comment: args.Comment,
RawData: args.RawData,
}

return coll.updateOrReplace(ctx, f, r, false, rrOne, false, args.Sort, updateOptions)
Expand Down Expand Up @@ -1519,6 +1525,9 @@ func (coll *Collection) find(
}
op.Sort(sort)
}
if args.RawData != nil {
op = op.RawData(*args.RawData)
}
retry := driver.RetryNone
if coll.client.retryReads {
retry = driver.RetryOncePerCommand
Expand Down Expand Up @@ -1552,6 +1561,7 @@ func newFindArgsFromFindOneArgs(args *options.FindOneOptions) *options.FindOptio
v.ShowRecordID = args.ShowRecordID
v.Skip = args.Skip
v.Sort = args.Sort
v.RawData = args.RawData
}
return v
}
Expand Down Expand Up @@ -1714,6 +1724,9 @@ func (coll *Collection) FindOneAndDelete(
}
op = op.Let(let)
}
if args.RawData != nil {
op = op.RawData(*args.RawData)
}

return coll.findAndModify(ctx, op)
}
Expand Down Expand Up @@ -1811,6 +1824,9 @@ func (coll *Collection) FindOneAndReplace(
}
op = op.Let(let)
}
if args.RawData != nil {
op = op.RawData(*args.RawData)
}

return coll.findAndModify(ctx, op)
}
Expand Down Expand Up @@ -1920,6 +1936,9 @@ func (coll *Collection) FindOneAndUpdate(
}
op = op.Let(let)
}
if args.RawData != nil {
op = op.RawData(*args.RawData)
}

return coll.findAndModify(ctx, op)
}
Expand Down
13 changes: 13 additions & 0 deletions mongo/options/bulkwriteoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type BulkWriteOptions struct {
Comment interface{}
Ordered *bool
Let interface{}
RawData *bool
}

// BulkWriteOptionsBuilder contains options to configure bulk write operations.
Expand Down Expand Up @@ -92,3 +93,15 @@ func (b *BulkWriteOptionsBuilder) SetLet(let interface{}) *BulkWriteOptionsBuild

return b
}

// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
func (b *BulkWriteOptionsBuilder) SetRawData(rawData bool) *BulkWriteOptionsBuilder {
b.Opts = append(b.Opts, func(opts *BulkWriteOptions) error {
opts.RawData = &rawData

return nil
})

return b
}
64 changes: 64 additions & 0 deletions mongo/options/findoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type FindOptions struct {
Let interface{}
Limit *int64
NoCursorTimeout *bool
RawData *bool
}

// FindOptionsBuilder represents functional options that configure an Findopts.
Expand Down Expand Up @@ -268,6 +269,18 @@ func (f *FindOptionsBuilder) SetSort(sort interface{}) *FindOptionsBuilder {
return f
}

// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
func (f *FindOptionsBuilder) SetRawData(rawData bool) *FindOptionsBuilder {
f.Opts = append(f.Opts, func(opts *FindOptions) error {
opts.RawData = &rawData

return nil
})

return f
}

// FindOneOptions represents arguments that can be used to configure a FindOne
// operation.
//
Expand All @@ -285,6 +298,7 @@ type FindOneOptions struct {
ShowRecordID *bool
Skip *int64
Sort interface{}
RawData *bool
}

// FindOneOptionsBuilder represents functional options that configure an
Expand Down Expand Up @@ -436,6 +450,17 @@ func (f *FindOneOptionsBuilder) SetSort(sort interface{}) *FindOneOptionsBuilder
return f
}

// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
func (f *FindOneOptionsBuilder) SetRawData(rawData bool) *FindOneOptionsBuilder {
f.Opts = append(f.Opts, func(opts *FindOneOptions) error {
opts.RawData = &rawData
return nil
})

return f
}

// FindOneAndReplaceOptions represents arguments that can be used to configure a
// FindOneAndReplace instance.
//
Expand All @@ -450,6 +475,7 @@ type FindOneAndReplaceOptions struct {
Upsert *bool
Hint interface{}
Let interface{}
RawData *bool
}

// FindOneAndReplaceOptionsBuilder contains options to perform a findAndModify
Expand Down Expand Up @@ -596,6 +622,18 @@ func (f *FindOneAndReplaceOptionsBuilder) SetLet(let interface{}) *FindOneAndRep
return f
}

// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
func (f *FindOneAndReplaceOptionsBuilder) SetRawData(rawData bool) *FindOneAndReplaceOptionsBuilder {
f.Opts = append(f.Opts, func(opts *FindOneAndReplaceOptions) error {
opts.RawData = &rawData

return nil
})

return f
}

// FindOneAndUpdateOptions represents arguments that can be used to configure a
// FindOneAndUpdate options.
//
Expand All @@ -611,6 +649,7 @@ type FindOneAndUpdateOptions struct {
Upsert *bool
Hint interface{}
Let interface{}
RawData *bool
}

// FindOneAndUpdateOptionsBuilder contains options to configure a
Expand Down Expand Up @@ -771,6 +810,18 @@ func (f *FindOneAndUpdateOptionsBuilder) SetLet(let interface{}) *FindOneAndUpda
return f
}

// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
func (f *FindOneAndUpdateOptionsBuilder) SetRawData(rawData bool) *FindOneAndUpdateOptionsBuilder {
f.Opts = append(f.Opts, func(opts *FindOneAndUpdateOptions) error {
opts.RawData = &rawData

return nil
})

return f
}

// FindOneAndDeleteOptions represents arguments that can be used to configure a
// FindOneAndDelete operation.
//
Expand All @@ -782,6 +833,7 @@ type FindOneAndDeleteOptions struct {
Sort interface{}
Hint interface{}
Let interface{}
RawData *bool
}

// FindOneAndDeleteOptionsBuilder contains options to configure delete
Expand Down Expand Up @@ -886,3 +938,15 @@ func (f *FindOneAndDeleteOptionsBuilder) SetLet(let interface{}) *FindOneAndDele

return f
}

// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
func (f *FindOneAndDeleteOptionsBuilder) SetRawData(rawData bool) *FindOneAndDeleteOptionsBuilder {
f.Opts = append(f.Opts, func(opts *FindOneAndDeleteOptions) error {
opts.RawData = &rawData

return nil
})

return f
}
13 changes: 13 additions & 0 deletions mongo/options/replaceoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ReplaceOptions struct {
Upsert *bool
Let interface{}
Sort interface{}
RawData *bool
}

// ReplaceOptionsBuilder contains options to configure replace operations. Each
Expand Down Expand Up @@ -136,3 +137,15 @@ func (ro *ReplaceOptionsBuilder) SetSort(s interface{}) *ReplaceOptionsBuilder {

return ro
}

// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries
// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false.
func (ro *ReplaceOptionsBuilder) SetRawData(rawData bool) *ReplaceOptionsBuilder {
ro.Opts = append(ro.Opts, func(opts *ReplaceOptions) error {
opts.RawData = &rawData

return nil
})

return ro
}
Loading
Loading