From 905599fb356b0e9e5d7e7049dbfe0bf8df400ae6 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Mon, 2 Jun 2025 16:46:45 -0400 Subject: [PATCH 1/9] WIP --- mongo/bulk_write.go | 13 ++++ mongo/client.go | 1 + mongo/client_bulk_write.go | 4 ++ mongo/collection.go | 49 +++++++++++-- mongo/options/aggregateoptions.go | 13 ++++ mongo/options/bulkwriteoptions.go | 13 ++++ mongo/options/clientbulkwriteoptions.go | 13 ++++ mongo/options/countoptions.go | 23 +++++-- mongo/options/deleteoptions.go | 42 +++++++++--- mongo/options/distinctoptions.go | 19 +++++- mongo/options/estimatedcountoptions.go | 15 +++- mongo/options/findoptions.go | 76 +++++++++++++++++++-- mongo/options/insertoptions.go | 26 +++++++ mongo/options/replaceoptions.go | 13 ++++ mongo/options/updateoptions.go | 26 +++++++ testdata/specifications | 2 +- x/mongo/driver/operation/aggregate.go | 14 ++++ x/mongo/driver/operation/count.go | 14 ++++ x/mongo/driver/operation/delete.go | 54 +++++++++------ x/mongo/driver/operation/distinct.go | 14 ++++ x/mongo/driver/operation/find.go | 14 ++++ x/mongo/driver/operation/find_and_modify.go | 14 ++++ x/mongo/driver/operation/insert.go | 14 ++++ x/mongo/driver/operation/update.go | 14 ++++ 24 files changed, 452 insertions(+), 48 deletions(-) diff --git a/mongo/bulk_write.go b/mongo/bulk_write.go index 415a90ae55..2feb05aa5f 100644 --- a/mongo/bulk_write.go +++ b/mongo/bulk_write.go @@ -39,6 +39,7 @@ type bulkWrite struct { writeConcern *writeconcern.WriteConcern result BulkWriteResult let interface{} + rawBucketsData *bool } func (bw *bulkWrite) execute(ctx context.Context) error { @@ -209,6 +210,10 @@ func (bw *bulkWrite) runInsert(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) + if bw.rawBucketsData != nil { + op.RawBucketsData(*bw.rawBucketsData) + } + err := op.Execute(ctx) return op.Result(), err @@ -282,6 +287,10 @@ func (bw *bulkWrite) runDelete(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) + if bw.rawBucketsData != nil { + op.RawBucketsData(*bw.rawBucketsData) + } + err := op.Execute(ctx) return op.Result(), err @@ -415,6 +424,10 @@ func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) + if bw.rawBucketsData != nil { + op.RawBucketsData(*bw.rawBucketsData) + } + err := op.Execute(ctx) return op.Result(), err diff --git a/mongo/client.go b/mongo/client.go index f3bf5ed5fb..75b474ddf2 100644 --- a/mongo/client.go +++ b/mongo/client.go @@ -956,6 +956,7 @@ func (c *Client) BulkWrite(ctx context.Context, writes []ClientBulkWrite, client: c, selector: selector, writeConcern: wc, + rawBucketsData: bwo.RawBucketsData, } if bwo.VerboseResults == nil || !(*bwo.VerboseResults) { op.errorsOnly = true diff --git a/mongo/client_bulk_write.go b/mongo/client_bulk_write.go index ca6ecf5240..9f9e85858c 100644 --- a/mongo/client_bulk_write.go +++ b/mongo/client_bulk_write.go @@ -44,6 +44,7 @@ type clientBulkWrite struct { client *Client selector description.ServerSelector writeConcern *writeconcern.WriteConcern + rawBucketsData *bool result ClientBulkWriteResult } @@ -143,6 +144,9 @@ func (bw *clientBulkWrite) newCommand() func([]byte, description.SelectedServer) } dst = bsoncore.AppendDocumentElement(dst, "let", let) } + if bw.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *bw.rawBucketsData) + } return dst, nil } } diff --git a/mongo/collection.go b/mongo/collection.go index d7693c4245..3f74b9e7ed 100644 --- a/mongo/collection.go +++ b/mongo/collection.go @@ -244,6 +244,7 @@ func (coll *Collection) BulkWrite(ctx context.Context, models []WriteModel, selector: selector, writeConcern: wc, let: args.Let, + rawBucketsData: args.RawBucketsData, } err = op.execute(ctx) @@ -324,6 +325,9 @@ func (coll *Collection) insert( if args.Ordered != nil { op = op.Ordered(*args.Ordered) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } retry := driver.RetryNone if coll.client.retryWrites { retry = driver.RetryOncePerCommand @@ -375,6 +379,9 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{}, if args.Comment != nil { imOpts.SetComment(args.Comment) } + if args.RawBucketsData != nil { + imOpts = imOpts.SetRawBucketsData(*args.RawBucketsData) + } res, err := coll.insert(ctx, []interface{}{document}, imOpts) rr, err := processWriteError(err) @@ -534,6 +541,9 @@ func (coll *Collection) delete( } op = op.Let(let) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } // deleteMany cannot be retried retryMode := driver.RetryNone @@ -571,10 +581,11 @@ func (coll *Collection) DeleteOne( return nil, fmt.Errorf("failed to construct options from builder: %w", err) } deleteOptions := &options.DeleteManyOptions{ - Collation: args.Collation, - Comment: args.Comment, - Hint: args.Hint, - Let: args.Let, + Collation: args.Collation, + Comment: args.Comment, + Hint: args.Hint, + Let: args.Let, + RawBucketsData: args.RawBucketsData, } return coll.delete(ctx, filter, true, rrOne, deleteOptions) @@ -681,6 +692,9 @@ func (coll *Collection) updateOrReplace( } op = op.Comment(comment) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } retry := driver.RetryNone // retryable writes are only enabled updateOne/replaceOne operations if !multi && coll.client.retryWrites { @@ -775,6 +789,7 @@ func (coll *Collection) UpdateOne( Hint: args.Hint, Upsert: args.Upsert, Let: args.Let, + RawBucketsData: args.RawBucketsData, } return coll.updateOrReplace(ctx, f, update, false, rrOne, true, args.Sort, updateOptions) @@ -865,6 +880,7 @@ func (coll *Collection) ReplaceOne( Hint: args.Hint, Let: args.Let, Comment: args.Comment, + RawBucketsData: args.RawBucketsData, } return coll.updateOrReplace(ctx, f, r, false, rrOne, false, args.Sort, updateOptions) @@ -1036,6 +1052,9 @@ func aggregate(a aggregateParams, opts ...options.Lister[options.AggregateOption } op.CustomOptions(customOptions) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } retry := driver.RetryNone if a.retryRead && !hasOutputStage { @@ -1124,6 +1143,9 @@ func (coll *Collection) CountDocuments(ctx context.Context, filter interface{}, } op.Hint(hintVal) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1205,6 +1227,9 @@ func (coll *Collection) EstimatedDocumentCount( } op = op.Comment(comment) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } retry := driver.RetryNone if coll.client.retryReads { @@ -1294,6 +1319,9 @@ func (coll *Collection) Distinct( } op.Hint(hint) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1497,6 +1525,9 @@ func (coll *Collection) find( } op.Sort(sort) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1530,6 +1561,7 @@ func newFindArgsFromFindOneArgs(args *options.FindOneOptions) *options.FindOptio v.ShowRecordID = args.ShowRecordID v.Skip = args.Skip v.Sort = args.Sort + v.RawBucketsData = args.RawBucketsData } return v } @@ -1692,6 +1724,9 @@ func (coll *Collection) FindOneAndDelete( } op = op.Let(let) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } return coll.findAndModify(ctx, op) } @@ -1789,6 +1824,9 @@ func (coll *Collection) FindOneAndReplace( } op = op.Let(let) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } return coll.findAndModify(ctx, op) } @@ -1898,6 +1936,9 @@ func (coll *Collection) FindOneAndUpdate( } op = op.Let(let) } + if args.RawBucketsData != nil { + op = op.RawBucketsData(*args.RawBucketsData) + } return coll.findAndModify(ctx, op) } diff --git a/mongo/options/aggregateoptions.go b/mongo/options/aggregateoptions.go index cf419677dc..1144275d59 100644 --- a/mongo/options/aggregateoptions.go +++ b/mongo/options/aggregateoptions.go @@ -26,6 +26,7 @@ type AggregateOptions struct { Hint interface{} Let interface{} Custom bson.M + RawBucketsData *bool } // AggregateOptionsBuilder contains options to configure aggregate operations. @@ -163,3 +164,15 @@ func (ao *AggregateOptionsBuilder) SetCustom(c bson.M) *AggregateOptionsBuilder return ao } + +// SetRawBucketsData sets the value for the RawBucketsData 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 (ao *AggregateOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *AggregateOptionsBuilder { + ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return ao +} diff --git a/mongo/options/bulkwriteoptions.go b/mongo/options/bulkwriteoptions.go index 186e83a0c5..98b74b5678 100644 --- a/mongo/options/bulkwriteoptions.go +++ b/mongo/options/bulkwriteoptions.go @@ -18,6 +18,7 @@ type BulkWriteOptions struct { Comment interface{} Ordered *bool Let interface{} + RawBucketsData *bool } // BulkWriteOptionsBuilder contains options to configure bulk write operations. @@ -92,3 +93,15 @@ func (b *BulkWriteOptionsBuilder) SetLet(let interface{}) *BulkWriteOptionsBuild return b } + +// SetRawBucketsData sets the value for the RawBucketsData 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) SetRawBucketsData(rawBucketsData bool) *BulkWriteOptionsBuilder { + b.Opts = append(b.Opts, func(opts *BulkWriteOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return b +} diff --git a/mongo/options/clientbulkwriteoptions.go b/mongo/options/clientbulkwriteoptions.go index a55ac27f05..61fe02d66a 100644 --- a/mongo/options/clientbulkwriteoptions.go +++ b/mongo/options/clientbulkwriteoptions.go @@ -19,6 +19,7 @@ type ClientBulkWriteOptions struct { Ordered *bool Let interface{} WriteConcern *writeconcern.WriteConcern + RawBucketsData *bool VerboseResults *bool } @@ -108,6 +109,18 @@ func (b *ClientBulkWriteOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteCo return b } +// SetRawBucketsData sets the value for the RawBucketsData 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 *ClientBulkWriteOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *ClientBulkWriteOptionsBuilder { + b.Opts = append(b.Opts, func(opts *ClientBulkWriteOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return b +} + // SetVerboseResults sets the value for the VerboseResults field. Specifies whether detailed // results for each successful operation should be included in the returned BulkWriteResult. // The defaults value is false. diff --git a/mongo/options/countoptions.go b/mongo/options/countoptions.go index 27df828b00..1485c8427c 100644 --- a/mongo/options/countoptions.go +++ b/mongo/options/countoptions.go @@ -11,11 +11,12 @@ package options // // See corresponding setter methods for documentation. type CountOptions struct { - Collation *Collation - Comment interface{} - Hint interface{} - Limit *int64 - Skip *int64 + Collation *Collation + Comment interface{} + Hint interface{} + Limit *int64 + Skip *int64 + RawBucketsData *bool } // CountOptionsBuilder contains options to configure count operations. Each @@ -99,3 +100,15 @@ func (co *CountOptionsBuilder) SetSkip(i int64) *CountOptionsBuilder { return co } + +// SetRawBucketsData sets the value for the RawBucketsData 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 (co *CountOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *CountOptionsBuilder { + co.Opts = append(co.Opts, func(opts *CountOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return co +} diff --git a/mongo/options/deleteoptions.go b/mongo/options/deleteoptions.go index 1d045d9960..435b65739b 100644 --- a/mongo/options/deleteoptions.go +++ b/mongo/options/deleteoptions.go @@ -11,10 +11,11 @@ package options // // See corresponding setter methods for documentation. type DeleteOneOptions struct { - Collation *Collation - Comment interface{} - Hint interface{} - Let interface{} + Collation *Collation + Comment interface{} + Hint interface{} + Let interface{} + RawBucketsData *bool } // DeleteOneOptionsBuilder contains options to configure DeleteOne operations. Each @@ -93,15 +94,28 @@ func (do *DeleteOneOptionsBuilder) SetLet(let interface{}) *DeleteOneOptionsBuil return do } +// SetRawBucketsData sets the value for the RawBucketsData 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 (do *DeleteOneOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *DeleteOneOptionsBuilder { + do.Opts = append(do.Opts, func(opts *DeleteOneOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return do +} + // DeleteManyOptions represents arguments that can be used to configure DeleteMany // operations. // // See corresponding setter methods for documentation. type DeleteManyOptions struct { - Collation *Collation - Comment interface{} - Hint interface{} - Let interface{} + Collation *Collation + Comment interface{} + Hint interface{} + Let interface{} + RawBucketsData *bool } // DeleteManyOptionsBuilder contains options to configure DeleteMany operations. @@ -179,3 +193,15 @@ func (do *DeleteManyOptionsBuilder) SetLet(let interface{}) *DeleteManyOptionsBu return do } + +// SetRawBucketsData sets the value for the RawBucketsData 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 (do *DeleteManyOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *DeleteManyOptionsBuilder { + do.Opts = append(do.Opts, func(opts *DeleteManyOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return do +} diff --git a/mongo/options/distinctoptions.go b/mongo/options/distinctoptions.go index 3449ecee36..e264aef666 100644 --- a/mongo/options/distinctoptions.go +++ b/mongo/options/distinctoptions.go @@ -11,9 +11,10 @@ package options // // See corresponding setter methods for documentation. type DistinctOptions struct { - Collation *Collation - Comment interface{} - Hint interface{} + Collation *Collation + Comment interface{} + Hint interface{} + RawBucketsData *bool } // DistinctOptionsBuilder contains options to configure distinct operations. Each @@ -77,3 +78,15 @@ func (do *DistinctOptionsBuilder) SetHint(hint interface{}) *DistinctOptionsBuil return do } + +// SetRawBucketsData sets the value for the RawBucketsData 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 (do *DistinctOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *DistinctOptionsBuilder { + do.Opts = append(do.Opts, func(opts *DistinctOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return do +} diff --git a/mongo/options/estimatedcountoptions.go b/mongo/options/estimatedcountoptions.go index 2bee45a8f6..01d698663d 100644 --- a/mongo/options/estimatedcountoptions.go +++ b/mongo/options/estimatedcountoptions.go @@ -11,7 +11,8 @@ package options // // See corresponding setter methods for documentation. type EstimatedDocumentCountOptions struct { - Comment interface{} + Comment interface{} + RawBucketsData *bool } // EstimatedDocumentCountOptionsBuilder contains options to estimate document @@ -44,3 +45,15 @@ func (eco *EstimatedDocumentCountOptionsBuilder) SetComment(comment interface{}) return eco } + +// SetRawBucketsData sets the value for the RawBucketsData 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 (eco *EstimatedDocumentCountOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *EstimatedDocumentCountOptionsBuilder { + eco.Opts = append(eco.Opts, func(opts *EstimatedDocumentCountOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return eco +} diff --git a/mongo/options/findoptions.go b/mongo/options/findoptions.go index ea627900ea..7cb6ebe263 100644 --- a/mongo/options/findoptions.go +++ b/mongo/options/findoptions.go @@ -35,6 +35,7 @@ type FindOptions struct { Let interface{} Limit *int64 NoCursorTimeout *bool + RawBucketsData *bool } // FindOptionsBuilder represents functional options that configure an Findopts. @@ -268,6 +269,18 @@ func (f *FindOptionsBuilder) SetSort(sort interface{}) *FindOptionsBuilder { return f } +// SetRawBucketsData sets the value for the RawBucketsData 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) SetRawBucketsData(rawBucketsData bool) *FindOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return f +} + // FindOneOptions represents arguments that can be used to configure a FindOne // operation. // @@ -285,6 +298,7 @@ type FindOneOptions struct { ShowRecordID *bool Skip *int64 Sort interface{} + RawBucketsData *bool } // FindOneOptionsBuilder represents functional options that configure an @@ -436,6 +450,17 @@ func (f *FindOneOptionsBuilder) SetSort(sort interface{}) *FindOneOptionsBuilder return f } +// SetRawBucketsData sets the value for the RawBucketsData 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) SetRawBucketsData(rawBucketsData bool) *FindOneOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOneOptions) error { + opts.RawBucketsData = &rawBucketsData + return nil + }) + + return f +} + // FindOneAndReplaceOptions represents arguments that can be used to configure a // FindOneAndReplace instance. // @@ -450,6 +475,7 @@ type FindOneAndReplaceOptions struct { Upsert *bool Hint interface{} Let interface{} + RawBucketsData *bool } // FindOneAndReplaceOptionsBuilder contains options to perform a findAndModify @@ -596,6 +622,18 @@ func (f *FindOneAndReplaceOptionsBuilder) SetLet(let interface{}) *FindOneAndRep return f } +// SetRawBucketsData sets the value for the RawBucketsData 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) SetRawBucketsData(rawBucketsData bool) *FindOneAndReplaceOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOneAndReplaceOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return f +} + // FindOneAndUpdateOptions represents arguments that can be used to configure a // FindOneAndUpdate options. // @@ -611,6 +649,7 @@ type FindOneAndUpdateOptions struct { Upsert *bool Hint interface{} Let interface{} + RawBucketsData *bool } // FindOneAndUpdateOptionsBuilder contains options to configure a @@ -771,17 +810,30 @@ func (f *FindOneAndUpdateOptionsBuilder) SetLet(let interface{}) *FindOneAndUpda return f } +// SetRawBucketsData sets the value for the RawBucketsData 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) SetRawBucketsData(rawBucketsData bool) *FindOneAndUpdateOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOneAndUpdateOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return f +} + // FindOneAndDeleteOptions represents arguments that can be used to configure a // FindOneAndDelete operation. // // See corresponding setter methods for documentation. type FindOneAndDeleteOptions struct { - Collation *Collation - Comment interface{} - Projection interface{} - Sort interface{} - Hint interface{} - Let interface{} + Collation *Collation + Comment interface{} + Projection interface{} + Sort interface{} + Hint interface{} + Let interface{} + RawBucketsData *bool } // FindOneAndDeleteOptionsBuilder contains options to configure delete @@ -886,3 +938,15 @@ func (f *FindOneAndDeleteOptionsBuilder) SetLet(let interface{}) *FindOneAndDele return f } + +// SetRawBucketsData sets the value for the RawBucketsData 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) SetRawBucketsData(rawBucketsData bool) *FindOneAndDeleteOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOneAndDeleteOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return f +} diff --git a/mongo/options/insertoptions.go b/mongo/options/insertoptions.go index 61745600a9..3daf8d1267 100644 --- a/mongo/options/insertoptions.go +++ b/mongo/options/insertoptions.go @@ -13,6 +13,7 @@ package options type InsertOneOptions struct { BypassDocumentValidation *bool Comment interface{} + RawBucketsData *bool } // InsertOneOptionsBuilder represents functional options that configure an @@ -53,6 +54,18 @@ func (ioo *InsertOneOptionsBuilder) SetComment(comment interface{}) *InsertOneOp return ioo } +// SetRawBucketsData sets the value for the RawBucketsData 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 (ioo *InsertOneOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *InsertOneOptionsBuilder { + ioo.Opts = append(ioo.Opts, func(ioo *InsertOneOptions) error { + ioo.RawBucketsData = &rawBucketsData + + return nil + }) + + return ioo +} + // InsertManyOptions represents arguments that can be used to configure an // InsertMany operation. // @@ -61,6 +74,7 @@ type InsertManyOptions struct { BypassDocumentValidation *bool Comment interface{} Ordered *bool + RawBucketsData *bool } // InsertManyOptionsBuilder contains options to configure insert operations. @@ -121,3 +135,15 @@ func (imo *InsertManyOptionsBuilder) SetOrdered(b bool) *InsertManyOptionsBuilde return imo } + +// SetRawBucketsData sets the value for the RawBucketsData 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 (imo *InsertManyOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *InsertManyOptionsBuilder { + imo.Opts = append(imo.Opts, func(opts *InsertManyOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return imo +} diff --git a/mongo/options/replaceoptions.go b/mongo/options/replaceoptions.go index 32caceff16..590bb7cf6f 100644 --- a/mongo/options/replaceoptions.go +++ b/mongo/options/replaceoptions.go @@ -18,6 +18,7 @@ type ReplaceOptions struct { Upsert *bool Let interface{} Sort interface{} + RawBucketsData *bool } // ReplaceOptionsBuilder contains options to configure replace operations. Each @@ -136,3 +137,15 @@ func (ro *ReplaceOptionsBuilder) SetSort(s interface{}) *ReplaceOptionsBuilder { return ro } + +// SetRawBucketsData sets the value for the RawBucketsData 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) SetRawBucketsData(rawBucketsData bool) *ReplaceOptionsBuilder { + ro.Opts = append(ro.Opts, func(opts *ReplaceOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return ro +} diff --git a/mongo/options/updateoptions.go b/mongo/options/updateoptions.go index f7b22e6f84..f81d634a1a 100644 --- a/mongo/options/updateoptions.go +++ b/mongo/options/updateoptions.go @@ -19,6 +19,7 @@ type UpdateOneOptions struct { Upsert *bool Let interface{} Sort interface{} + RawBucketsData *bool } // UpdateOneOptionsBuilder contains options to configure UpdateOne operations. @@ -152,6 +153,18 @@ func (uo *UpdateOneOptionsBuilder) SetSort(s interface{}) *UpdateOneOptionsBuild return uo } +// SetRawBucketsData sets the value for the RawBucketsData 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 (uo *UpdateOneOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *UpdateOneOptionsBuilder { + uo.Opts = append(uo.Opts, func(opts *UpdateOneOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return uo +} + // UpdateManyOptions represents arguments that can be used to configure UpdateMany // operations. // @@ -164,6 +177,7 @@ type UpdateManyOptions struct { Hint interface{} Upsert *bool Let interface{} + RawBucketsData *bool } // UpdateManyOptionsBuilder contains options to configure UpdateMany operations. @@ -281,3 +295,15 @@ func (uo *UpdateManyOptionsBuilder) SetLet(l interface{}) *UpdateManyOptionsBuil return uo } + +// SetRawBucketsData sets the value for the RawBucketsData 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 (uo *UpdateManyOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *UpdateManyOptionsBuilder { + uo.Opts = append(uo.Opts, func(opts *UpdateManyOptions) error { + opts.RawBucketsData = &rawBucketsData + + return nil + }) + + return uo +} diff --git a/testdata/specifications b/testdata/specifications index 9d0d3f0042..f4c0bbdbf8 160000 --- a/testdata/specifications +++ b/testdata/specifications @@ -1 +1 @@ -Subproject commit 9d0d3f0042a8cf5faeb47ae7765716151bfca9ef +Subproject commit f4c0bbdbf8a8560580c947ca2c331794431a0c78 diff --git a/x/mongo/driver/operation/aggregate.go b/x/mongo/driver/operation/aggregate.go index a0cd5bd25e..b98821322c 100644 --- a/x/mongo/driver/operation/aggregate.go +++ b/x/mongo/driver/operation/aggregate.go @@ -50,6 +50,7 @@ type Aggregate struct { customOptions map[string]bsoncore.Value timeout *time.Duration omitMaxTimeMS bool + rawBucketsData *bool result driver.CursorResponse } @@ -159,6 +160,9 @@ func (a *Aggregate) command(dst []byte, desc description.SelectedServer) ([]byte if a.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", a.let) } + if a.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *a.rawBucketsData) + } for optionName, optionValue := range a.customOptions { dst = bsoncore.AppendValueElement(dst, optionName, optionValue) } @@ -431,3 +435,13 @@ func (a *Aggregate) OmitMaxTimeMS(omit bool) *Aggregate { a.omitMaxTimeMS = omit return a } + +// RawBucketsData sets the rawData to access timeseries data in the compressed format. +func (a *Aggregate) RawBucketsData(rawBucketsData bool) *Aggregate { + if a == nil { + a = new(Aggregate) + } + + a.rawBucketsData = &rawBucketsData + return a +} diff --git a/x/mongo/driver/operation/count.go b/x/mongo/driver/operation/count.go index 5ecaa3a936..84277ef50a 100644 --- a/x/mongo/driver/operation/count.go +++ b/x/mongo/driver/operation/count.go @@ -41,6 +41,7 @@ type Count struct { result CountResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawBucketsData *bool } // CountResult represents a count result returned by the server. @@ -147,6 +148,9 @@ func (c *Count) command(dst []byte, _ description.SelectedServer) ([]byte, error if c.comment.Type != bsoncore.Type(0) { dst = bsoncore.AppendValueElement(dst, "comment", c.comment) } + if c.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *c.rawBucketsData) + } return dst, nil } @@ -310,3 +314,13 @@ func (c *Count) Authenticator(authenticator driver.Authenticator) *Count { c.authenticator = authenticator return c } + +// RawBucketsData sets the rawData to access timeseries data in the compressed format. +func (c *Count) RawBucketsData(rawBucketsData bool) *Count { + if c == nil { + c = new(Count) + } + + c.rawBucketsData = &rawBucketsData + return c +} diff --git a/x/mongo/driver/operation/delete.go b/x/mongo/driver/operation/delete.go index e6f47042a8..e8367ad8cf 100644 --- a/x/mongo/driver/operation/delete.go +++ b/x/mongo/driver/operation/delete.go @@ -24,26 +24,27 @@ import ( // Delete performs a delete operation type Delete struct { - authenticator driver.Authenticator - comment bsoncore.Value - deletes []bsoncore.Document - ordered *bool - session *session.Client - clock *session.ClusterClock - collection string - monitor *event.CommandMonitor - crypt driver.Crypt - database string - deployment driver.Deployment - selector description.ServerSelector - writeConcern *writeconcern.WriteConcern - retry *driver.RetryMode - hint *bool - result DeleteResult - serverAPI *driver.ServerAPIOptions - let bsoncore.Document - timeout *time.Duration - logger *logger.Logger + authenticator driver.Authenticator + comment bsoncore.Value + deletes []bsoncore.Document + ordered *bool + session *session.Client + clock *session.ClusterClock + collection string + monitor *event.CommandMonitor + crypt driver.Crypt + database string + deployment driver.Deployment + selector description.ServerSelector + writeConcern *writeconcern.WriteConcern + retry *driver.RetryMode + hint *bool + result DeleteResult + serverAPI *driver.ServerAPIOptions + let bsoncore.Document + timeout *time.Duration + rawBucketsData *bool + logger *logger.Logger } // DeleteResult represents a delete result returned by the server. @@ -139,6 +140,9 @@ func (d *Delete) command(dst []byte, desc description.SelectedServer) ([]byte, e if d.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", d.let) } + if d.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawBucketsData) + } return dst, nil } @@ -337,3 +341,13 @@ func (d *Delete) Authenticator(authenticator driver.Authenticator) *Delete { d.authenticator = authenticator return d } + +// RawBucketsData sets the rawData to access timeseries data in the compressed format. +func (d *Delete) RawBucketsData(rawBucketsData bool) *Delete { + if d == nil { + d = new(Delete) + } + + d.rawBucketsData = &rawBucketsData + return d +} diff --git a/x/mongo/driver/operation/distinct.go b/x/mongo/driver/operation/distinct.go index 89d412def3..8feaa9e7c5 100644 --- a/x/mongo/driver/operation/distinct.go +++ b/x/mongo/driver/operation/distinct.go @@ -43,6 +43,7 @@ type Distinct struct { result DistinctResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawBucketsData *bool } // DistinctResult represents a distinct result returned by the server. @@ -130,6 +131,9 @@ func (d *Distinct) command(dst []byte, desc description.SelectedServer) ([]byte, if d.query != nil { dst = bsoncore.AppendDocumentElement(dst, "query", d.query) } + if d.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawBucketsData) + } return dst, nil } @@ -323,3 +327,13 @@ func (d *Distinct) Authenticator(authenticator driver.Authenticator) *Distinct { d.authenticator = authenticator return d } + +// RawBucketsData sets the rawData to access timeseries data in the compressed format. +func (d *Distinct) RawBucketsData(rawBucketsData bool) *Distinct { + if d == nil { + d = new(Distinct) + } + + d.rawBucketsData = &rawBucketsData + return d +} diff --git a/x/mongo/driver/operation/find.go b/x/mongo/driver/operation/find.go index b607cb14d7..ba48b31a87 100644 --- a/x/mongo/driver/operation/find.go +++ b/x/mongo/driver/operation/find.go @@ -61,6 +61,7 @@ type Find struct { result driver.CursorResponse serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawBucketsData *bool logger *logger.Logger omitMaxTimeMS bool } @@ -191,6 +192,9 @@ func (f *Find) command(dst []byte, desc description.SelectedServer) ([]byte, err if f.tailable != nil { dst = bsoncore.AppendBooleanElement(dst, "tailable", *f.tailable) } + if f.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *f.rawBucketsData) + } return dst, nil } @@ -565,6 +569,16 @@ func (f *Find) Authenticator(authenticator driver.Authenticator) *Find { return f } +// RawBucketsData sets the rawData to access timeseries data in the compressed format. +func (f *Find) RawBucketsData(rawBucketsData bool) *Find { + if f == nil { + f = new(Find) + } + + f.rawBucketsData = &rawBucketsData + return f +} + // OmitMaxTimeMS omits the automatically-calculated "maxTimeMS" from the // command. func (f *Find) OmitMaxTimeMS(omit bool) *Find { diff --git a/x/mongo/driver/operation/find_and_modify.go b/x/mongo/driver/operation/find_and_modify.go index 505c56b06c..ff1840b1bf 100644 --- a/x/mongo/driver/operation/find_and_modify.go +++ b/x/mongo/driver/operation/find_and_modify.go @@ -50,6 +50,7 @@ type FindAndModify struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration + rawBucketsData *bool result FindAndModifyResult } @@ -211,6 +212,9 @@ func (fam *FindAndModify) command(dst []byte, desc description.SelectedServer) ( if fam.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", fam.let) } + if fam.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *fam.rawBucketsData) + } return dst, nil } @@ -476,3 +480,13 @@ func (fam *FindAndModify) Authenticator(authenticator driver.Authenticator) *Fin fam.authenticator = authenticator return fam } + +// RawBucketsData sets the rawData to access timeseries data in the compressed format. +func (fam *FindAndModify) RawBucketsData(rawBucketsData bool) *FindAndModify { + if fam == nil { + fam = new(FindAndModify) + } + + fam.rawBucketsData = &rawBucketsData + return fam +} diff --git a/x/mongo/driver/operation/insert.go b/x/mongo/driver/operation/insert.go index b48e2c85f3..94948c08be 100644 --- a/x/mongo/driver/operation/insert.go +++ b/x/mongo/driver/operation/insert.go @@ -42,6 +42,7 @@ type Insert struct { result InsertResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawBucketsData *bool logger *logger.Logger } @@ -132,6 +133,9 @@ func (i *Insert) command(dst []byte, desc description.SelectedServer) ([]byte, e if i.ordered != nil { dst = bsoncore.AppendBooleanElement(dst, "ordered", *i.ordered) } + if i.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *i.rawBucketsData) + } return dst, nil } @@ -318,3 +322,13 @@ func (i *Insert) Authenticator(authenticator driver.Authenticator) *Insert { i.authenticator = authenticator return i } + +// RawBucketsData sets the rawData to access timeseries data in the compressed format. +func (i *Insert) RawBucketsData(rawBucketsData bool) *Insert { + if i == nil { + i = new(Insert) + } + + i.rawBucketsData = &rawBucketsData + return i +} diff --git a/x/mongo/driver/operation/update.go b/x/mongo/driver/operation/update.go index 722c06ef94..ace7521f62 100644 --- a/x/mongo/driver/operation/update.go +++ b/x/mongo/driver/operation/update.go @@ -46,6 +46,7 @@ type Update struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration + rawBucketsData *bool logger *logger.Logger } @@ -203,6 +204,9 @@ func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, e if u.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", u.let) } + if u.rawBucketsData != nil { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawBucketsData) + } return dst, nil } @@ -422,3 +426,13 @@ func (u *Update) Authenticator(authenticator driver.Authenticator) *Update { u.authenticator = authenticator return u } + +// RawBucketsData sets the rawData to access timeseries data in the compressed format. +func (u *Update) RawBucketsData(rawBucketsData bool) *Update { + if u == nil { + u = new(Update) + } + + u.rawBucketsData = &rawBucketsData + return u +} From f014b7d473e27d354ed67c20a5a8ff985e0034d7 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Mon, 9 Jun 2025 17:29:59 -0400 Subject: [PATCH 2/9] WIP --- .gitmodules | 3 ++- internal/integration/unified/collection_operation_execution.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index e3b5c7b3ee..a403967b4e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "specifications"] path = testdata/specifications - url = https://github.com/mongodb/specifications + url = https://github.com/qingyang-hu/specifications.git + branch = drivers3064 diff --git a/internal/integration/unified/collection_operation_execution.go b/internal/integration/unified/collection_operation_execution.go index c3e7040256..20fc5a01ca 100644 --- a/internal/integration/unified/collection_operation_execution.go +++ b/internal/integration/unified/collection_operation_execution.go @@ -1500,6 +1500,8 @@ func createFindCursor(ctx context.Context, operation *operation) (*cursorResult, case "maxAwaitTimeMS": maxAwaitTimeMS := time.Duration(val.Int32()) * time.Millisecond opts.SetMaxAwaitTime(maxAwaitTimeMS) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized find option %q", key) } From 106c333a0fe73eff7c86f10f02b820568f1e210f Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Thu, 26 Jun 2025 11:47:14 -0400 Subject: [PATCH 3/9] WIP --- .../unified/collection_operation_execution.go | 18 ++++++++++++++++++ internal/integration/unified/crud_helpers.go | 4 ++++ x/mongo/driver/operation/delete.go | 3 ++- x/mongo/driver/operation/distinct.go | 3 ++- x/mongo/driver/operation/find.go | 3 ++- x/mongo/driver/operation/find_and_modify.go | 3 ++- x/mongo/driver/operation/insert.go | 3 ++- x/mongo/driver/operation/update.go | 3 ++- 8 files changed, 34 insertions(+), 6 deletions(-) diff --git a/internal/integration/unified/collection_operation_execution.go b/internal/integration/unified/collection_operation_execution.go index 20fc5a01ca..5eb8443669 100644 --- a/internal/integration/unified/collection_operation_execution.go +++ b/internal/integration/unified/collection_operation_execution.go @@ -433,6 +433,8 @@ func executeDeleteOne(ctx context.Context, operation *operation) (*operationResu opts.SetHint(hint) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized deleteOne option %q", key) } @@ -487,6 +489,8 @@ func executeDeleteMany(ctx context.Context, operation *operation) (*operationRes opts.SetHint(hint) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized deleteMany option %q", key) } @@ -545,6 +549,8 @@ func executeDistinct(ctx context.Context, operation *operation) (*operationResul // ensured an analogue exists, extend "skippedTestDescriptions" to avoid // this error. return nil, fmt.Errorf("the maxTimeMS collection option is not supported") + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized distinct option %q", key) } @@ -842,6 +848,8 @@ func executeFindOneAndDelete(ctx context.Context, operation *operation) (*operat opts.SetSort(val.Document()) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndDelete option %q", key) } @@ -924,6 +932,8 @@ func executeFindOneAndReplace(ctx context.Context, operation *operation) (*opera opts.SetSort(val.Document()) case "upsert": opts.SetUpsert(val.Boolean()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndReplace option %q", key) } @@ -1016,6 +1026,8 @@ func executeFindOneAndUpdate(ctx context.Context, operation *operation) (*operat } case "upsert": opts.SetUpsert(val.Boolean()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndUpdate option %q", key) } @@ -1062,6 +1074,8 @@ func executeInsertMany(ctx context.Context, operation *operation) (*operationRes documents = bsonutil.RawToInterfaces(bsonutil.RawArrayToDocuments(val.Array())...) case "ordered": opts.SetOrdered(val.Boolean()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized insertMany option %q", key) } @@ -1112,6 +1126,8 @@ func executeInsertOne(ctx context.Context, operation *operation) (*operationResu opts.SetBypassDocumentValidation(val.Boolean()) case "comment": opts.SetComment(val) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized insertOne option %q", key) } @@ -1302,6 +1318,8 @@ func executeReplaceOne(ctx context.Context, operation *operation) (*operationRes opts.SetUpsert(val.Boolean()) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized replaceOne option %q", key) } diff --git a/internal/integration/unified/crud_helpers.go b/internal/integration/unified/crud_helpers.go index 34de29d683..8cf0309f06 100644 --- a/internal/integration/unified/crud_helpers.go +++ b/internal/integration/unified/crud_helpers.go @@ -67,6 +67,8 @@ func createUpdateManyArguments(args bson.Raw) (*updateArguments, *options.Update } case "upsert": opts.SetUpsert(val.Boolean()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, nil, fmt.Errorf("unrecognized update option %q", key) } @@ -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.SetRawBucketsData(val.Boolean()) default: return nil, nil, fmt.Errorf("unrecognized update option %q", key) } diff --git a/x/mongo/driver/operation/delete.go b/x/mongo/driver/operation/delete.go index e8367ad8cf..a0465845e1 100644 --- a/x/mongo/driver/operation/delete.go +++ b/x/mongo/driver/operation/delete.go @@ -140,7 +140,8 @@ func (d *Delete) command(dst []byte, desc description.SelectedServer) ([]byte, e if d.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", d.let) } - if d.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if d.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawBucketsData) } return dst, nil diff --git a/x/mongo/driver/operation/distinct.go b/x/mongo/driver/operation/distinct.go index 8feaa9e7c5..b424ce801c 100644 --- a/x/mongo/driver/operation/distinct.go +++ b/x/mongo/driver/operation/distinct.go @@ -131,7 +131,8 @@ func (d *Distinct) command(dst []byte, desc description.SelectedServer) ([]byte, if d.query != nil { dst = bsoncore.AppendDocumentElement(dst, "query", d.query) } - if d.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if d.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawBucketsData) } return dst, nil diff --git a/x/mongo/driver/operation/find.go b/x/mongo/driver/operation/find.go index ba48b31a87..1f7d906d29 100644 --- a/x/mongo/driver/operation/find.go +++ b/x/mongo/driver/operation/find.go @@ -192,7 +192,8 @@ func (f *Find) command(dst []byte, desc description.SelectedServer) ([]byte, err if f.tailable != nil { dst = bsoncore.AppendBooleanElement(dst, "tailable", *f.tailable) } - if f.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if f.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *f.rawBucketsData) } return dst, nil diff --git a/x/mongo/driver/operation/find_and_modify.go b/x/mongo/driver/operation/find_and_modify.go index ff1840b1bf..bf01bb0745 100644 --- a/x/mongo/driver/operation/find_and_modify.go +++ b/x/mongo/driver/operation/find_and_modify.go @@ -212,7 +212,8 @@ func (fam *FindAndModify) command(dst []byte, desc description.SelectedServer) ( if fam.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", fam.let) } - if fam.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if fam.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *fam.rawBucketsData) } diff --git a/x/mongo/driver/operation/insert.go b/x/mongo/driver/operation/insert.go index 94948c08be..cdb479ff69 100644 --- a/x/mongo/driver/operation/insert.go +++ b/x/mongo/driver/operation/insert.go @@ -133,7 +133,8 @@ func (i *Insert) command(dst []byte, desc description.SelectedServer) ([]byte, e if i.ordered != nil { dst = bsoncore.AppendBooleanElement(dst, "ordered", *i.ordered) } - if i.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if i.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *i.rawBucketsData) } return dst, nil diff --git a/x/mongo/driver/operation/update.go b/x/mongo/driver/operation/update.go index ace7521f62..b30badf465 100644 --- a/x/mongo/driver/operation/update.go +++ b/x/mongo/driver/operation/update.go @@ -204,7 +204,8 @@ func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, e if u.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", u.let) } - if u.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if u.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawBucketsData) } From 5aae947ea2d8b0abe0adb0550ba947f689fcdd14 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Thu, 26 Jun 2025 16:35:53 -0400 Subject: [PATCH 4/9] WIP --- .../integration/unified/client_operation_execution.go | 2 ++ .../integration/unified/collection_operation_execution.go | 8 ++++++++ mongo/client_bulk_write.go | 3 ++- x/mongo/driver/operation/aggregate.go | 3 ++- x/mongo/driver/operation/count.go | 5 +++-- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/internal/integration/unified/client_operation_execution.go b/internal/integration/unified/client_operation_execution.go index 75948ff8a0..a0d94b6ee1 100644 --- a/internal/integration/unified/client_operation_execution.go +++ b/internal/integration/unified/client_operation_execution.go @@ -235,6 +235,8 @@ func executeClientBulkWrite(ctx context.Context, operation *operation) (*operati return nil, err } opts.SetWriteConcern(c) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized bulkWrite option %q", key) } diff --git a/internal/integration/unified/collection_operation_execution.go b/internal/integration/unified/collection_operation_execution.go index 5eb8443669..144ed60c4a 100644 --- a/internal/integration/unified/collection_operation_execution.go +++ b/internal/integration/unified/collection_operation_execution.go @@ -75,6 +75,8 @@ func executeAggregate(ctx context.Context, operation *operation) (*operationResu pipeline = bsonutil.RawToInterfaces(bsonutil.RawArrayToDocuments(val.Array())...) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized aggregate option %q", key) } @@ -125,6 +127,8 @@ func executeBulkWrite(ctx context.Context, operation *operation) (*operationResu } case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized bulkWrite option %q", key) } @@ -202,6 +206,8 @@ func executeCountDocuments(ctx context.Context, operation *operation) (*operatio return nil, fmt.Errorf("the maxTimeMS collection option is not supported") case "skip": opts.SetSkip(int64(val.Int32())) + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized countDocuments option %q", key) } @@ -696,6 +702,8 @@ func executeEstimatedDocumentCount(ctx context.Context, operation *operation) (* // ensured an analogue exists, extend "skippedTestDescriptions" to avoid // this error. return nil, fmt.Errorf("the maxTimeMS collection option is not supported") + case "rawData": + opts.SetRawBucketsData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized estimatedDocumentCount option %q", key) } diff --git a/mongo/client_bulk_write.go b/mongo/client_bulk_write.go index 9f9e85858c..2873ebd985 100644 --- a/mongo/client_bulk_write.go +++ b/mongo/client_bulk_write.go @@ -144,7 +144,8 @@ func (bw *clientBulkWrite) newCommand() func([]byte, description.SelectedServer) } dst = bsoncore.AppendDocumentElement(dst, "let", let) } - if bw.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if bw.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *bw.rawBucketsData) } return dst, nil diff --git a/x/mongo/driver/operation/aggregate.go b/x/mongo/driver/operation/aggregate.go index b98821322c..aef778c0bf 100644 --- a/x/mongo/driver/operation/aggregate.go +++ b/x/mongo/driver/operation/aggregate.go @@ -160,7 +160,8 @@ func (a *Aggregate) command(dst []byte, desc description.SelectedServer) ([]byte if a.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", a.let) } - if a.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if a.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *a.rawBucketsData) } for optionName, optionValue := range a.customOptions { diff --git a/x/mongo/driver/operation/count.go b/x/mongo/driver/operation/count.go index 84277ef50a..6b57414e22 100644 --- a/x/mongo/driver/operation/count.go +++ b/x/mongo/driver/operation/count.go @@ -140,7 +140,7 @@ func (c *Count) Execute(ctx context.Context) error { return err } -func (c *Count) command(dst []byte, _ description.SelectedServer) ([]byte, error) { +func (c *Count) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendStringElement(dst, "count", c.collection) if c.query != nil { dst = bsoncore.AppendDocumentElement(dst, "query", c.query) @@ -148,7 +148,8 @@ func (c *Count) command(dst []byte, _ description.SelectedServer) ([]byte, error if c.comment.Type != bsoncore.Type(0) { dst = bsoncore.AppendValueElement(dst, "comment", c.comment) } - if c.rawBucketsData != nil { + // Set rawData for 8.2+ servers. + if c.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { dst = bsoncore.AppendBooleanElement(dst, "rawData", *c.rawBucketsData) } return dst, nil From 3898773071441f3bdde5d1e74763915e2b9200d3 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Fri, 27 Jun 2025 20:07:55 -0400 Subject: [PATCH 5/9] update specs --- testdata/specifications | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/specifications b/testdata/specifications index f4c0bbdbf8..d6176ecbfb 160000 --- a/testdata/specifications +++ b/testdata/specifications @@ -1 +1 @@ -Subproject commit f4c0bbdbf8a8560580c947ca2c331794431a0c78 +Subproject commit d6176ecbfb5fbaa0e36619b72a873708b20bb20d From b502d9fd3bf9530a29512c5095ff06ba7380a8be Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Fri, 27 Jun 2025 20:08:16 -0400 Subject: [PATCH 6/9] WIP --- .../unified/client_operation_execution.go | 2 +- .../unified/collection_operation_execution.go | 38 ++++++----- internal/integration/unified/crud_helpers.go | 6 +- mongo/bulk_write.go | 14 ++-- mongo/client.go | 2 +- mongo/client_bulk_write.go | 6 +- mongo/collection.go | 66 +++++++++---------- mongo/database.go | 3 + mongo/index_view.go | 19 +++++- mongo/options/aggregateoptions.go | 8 +-- mongo/options/bulkwriteoptions.go | 8 +-- mongo/options/clientbulkwriteoptions.go | 8 +-- mongo/options/countoptions.go | 18 ++--- mongo/options/deleteoptions.go | 32 ++++----- mongo/options/distinctoptions.go | 14 ++-- mongo/options/estimatedcountoptions.go | 10 +-- mongo/options/findoptions.go | 52 +++++++-------- mongo/options/indexoptions.go | 42 +++++++++++- mongo/options/insertoptions.go | 16 ++--- mongo/options/listcollectionsoptions.go | 13 ++++ mongo/options/replaceoptions.go | 8 +-- mongo/options/updateoptions.go | 16 ++--- x/mongo/driver/operation/aggregate.go | 12 ++-- x/mongo/driver/operation/count.go | 12 ++-- x/mongo/driver/operation/create_indexes.go | 15 +++++ x/mongo/driver/operation/delete.go | 52 +++++++-------- x/mongo/driver/operation/distinct.go | 12 ++-- x/mongo/driver/operation/drop_indexes.go | 17 ++++- x/mongo/driver/operation/find.go | 12 ++-- x/mongo/driver/operation/find_and_modify.go | 12 ++-- x/mongo/driver/operation/insert.go | 12 ++-- x/mongo/driver/operation/list_collections.go | 18 ++++- x/mongo/driver/operation/list_indexes.go | 18 ++++- x/mongo/driver/operation/update.go | 12 ++-- 34 files changed, 373 insertions(+), 232 deletions(-) diff --git a/internal/integration/unified/client_operation_execution.go b/internal/integration/unified/client_operation_execution.go index a0d94b6ee1..9e7ab88e5f 100644 --- a/internal/integration/unified/client_operation_execution.go +++ b/internal/integration/unified/client_operation_execution.go @@ -236,7 +236,7 @@ func executeClientBulkWrite(ctx context.Context, operation *operation) (*operati } opts.SetWriteConcern(c) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized bulkWrite option %q", key) } diff --git a/internal/integration/unified/collection_operation_execution.go b/internal/integration/unified/collection_operation_execution.go index 144ed60c4a..3744707e0c 100644 --- a/internal/integration/unified/collection_operation_execution.go +++ b/internal/integration/unified/collection_operation_execution.go @@ -76,7 +76,7 @@ func executeAggregate(ctx context.Context, operation *operation) (*operationResu case "let": opts.SetLet(val.Document()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized aggregate option %q", key) } @@ -128,7 +128,7 @@ func executeBulkWrite(ctx context.Context, operation *operation) (*operationResu case "let": opts.SetLet(val.Document()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized bulkWrite option %q", key) } @@ -207,7 +207,7 @@ func executeCountDocuments(ctx context.Context, operation *operation) (*operatio case "skip": opts.SetSkip(int64(val.Int32())) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized countDocuments option %q", key) } @@ -231,6 +231,7 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe var keys bson.Raw indexOpts := options.Index() + opts := options.CreateIndexes() elems, err := operation.Arguments.Elements() if err != nil { @@ -285,6 +286,8 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe indexOpts.SetWeights(val.Document()) case "wildcardProjection": indexOpts.SetWildcardProjection(val.Document()) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized createIndex option %q", key) } @@ -297,7 +300,8 @@ func executeCreateIndex(ctx context.Context, operation *operation) (*operationRe Keys: keys, Options: indexOpts, } - name, err := coll.Indexes().CreateOne(ctx, model) + + name, err := coll.Indexes().CreateOne(ctx, model, opts) return newValueResult(bson.TypeString, bsoncore.AppendString(nil, name), err), nil } @@ -440,7 +444,7 @@ func executeDeleteOne(ctx context.Context, operation *operation) (*operationResu case "let": opts.SetLet(val.Document()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized deleteOne option %q", key) } @@ -496,7 +500,7 @@ func executeDeleteMany(ctx context.Context, operation *operation) (*operationRes case "let": opts.SetLet(val.Document()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized deleteMany option %q", key) } @@ -556,7 +560,7 @@ func executeDistinct(ctx context.Context, operation *operation) (*operationResul // this error. return nil, fmt.Errorf("the maxTimeMS collection option is not supported") case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized distinct option %q", key) } @@ -605,6 +609,8 @@ func executeDropIndex(ctx context.Context, operation *operation) (*operationResu // ensured an analogue exists, extend "skippedTestDescriptions" to avoid // this error. return nil, fmt.Errorf("the maxTimeMS collection option is not supported") + case "rawData": + dropIndexOpts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized dropIndex option %q", key) } @@ -703,7 +709,7 @@ func executeEstimatedDocumentCount(ctx context.Context, operation *operation) (* // this error. return nil, fmt.Errorf("the maxTimeMS collection option is not supported") case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized estimatedDocumentCount option %q", key) } @@ -857,7 +863,7 @@ func executeFindOneAndDelete(ctx context.Context, operation *operation) (*operat case "let": opts.SetLet(val.Document()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndDelete option %q", key) } @@ -941,7 +947,7 @@ func executeFindOneAndReplace(ctx context.Context, operation *operation) (*opera case "upsert": opts.SetUpsert(val.Boolean()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndReplace option %q", key) } @@ -1035,7 +1041,7 @@ func executeFindOneAndUpdate(ctx context.Context, operation *operation) (*operat case "upsert": opts.SetUpsert(val.Boolean()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndUpdate option %q", key) } @@ -1083,7 +1089,7 @@ func executeInsertMany(ctx context.Context, operation *operation) (*operationRes case "ordered": opts.SetOrdered(val.Boolean()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized insertMany option %q", key) } @@ -1135,7 +1141,7 @@ func executeInsertOne(ctx context.Context, operation *operation) (*operationResu case "comment": opts.SetComment(val) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized insertOne option %q", key) } @@ -1180,6 +1186,8 @@ func executeListIndexes(ctx context.Context, operation *operation) (*operationRe switch key { case "batchSize": opts.SetBatchSize(val.Int32()) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized listIndexes option: %q", key) } @@ -1327,7 +1335,7 @@ func executeReplaceOne(ctx context.Context, operation *operation) (*operationRes case "let": opts.SetLet(val.Document()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized replaceOne option %q", key) } @@ -1527,7 +1535,7 @@ func createFindCursor(ctx context.Context, operation *operation) (*cursorResult, maxAwaitTimeMS := time.Duration(val.Int32()) * time.Millisecond opts.SetMaxAwaitTime(maxAwaitTimeMS) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized find option %q", key) } diff --git a/internal/integration/unified/crud_helpers.go b/internal/integration/unified/crud_helpers.go index 8cf0309f06..aeda7ba0ec 100644 --- a/internal/integration/unified/crud_helpers.go +++ b/internal/integration/unified/crud_helpers.go @@ -68,7 +68,7 @@ func createUpdateManyArguments(args bson.Raw) (*updateArguments, *options.Update case "upsert": opts.SetUpsert(val.Boolean()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, nil, fmt.Errorf("unrecognized update option %q", key) } @@ -128,7 +128,7 @@ func createUpdateOneArguments(args bson.Raw) (*updateArguments, *options.UpdateO case "sort": opts.SetSort(val.Document()) case "rawData": - opts.SetRawBucketsData(val.Boolean()) + opts.SetRawData(val.Boolean()) default: return nil, nil, fmt.Errorf("unrecognized update option %q", key) } @@ -166,6 +166,8 @@ func createListCollectionsArguments(args bson.Raw) (*listCollectionsArguments, e lca.filter = val.Document() case "nameOnly": lca.opts.SetNameOnly(val.Boolean()) + case "rawData": + lca.opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized listCollections option %q", key) } diff --git a/mongo/bulk_write.go b/mongo/bulk_write.go index 2feb05aa5f..7a3181c6c4 100644 --- a/mongo/bulk_write.go +++ b/mongo/bulk_write.go @@ -39,7 +39,7 @@ type bulkWrite struct { writeConcern *writeconcern.WriteConcern result BulkWriteResult let interface{} - rawBucketsData *bool + rawData *bool } func (bw *bulkWrite) execute(ctx context.Context) error { @@ -210,8 +210,8 @@ func (bw *bulkWrite) runInsert(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) - if bw.rawBucketsData != nil { - op.RawBucketsData(*bw.rawBucketsData) + if bw.rawData != nil { + op.RawData(*bw.rawData) } err := op.Execute(ctx) @@ -287,8 +287,8 @@ func (bw *bulkWrite) runDelete(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) - if bw.rawBucketsData != nil { - op.RawBucketsData(*bw.rawBucketsData) + if bw.rawData != nil { + op.RawData(*bw.rawData) } err := op.Execute(ctx) @@ -424,8 +424,8 @@ func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) - if bw.rawBucketsData != nil { - op.RawBucketsData(*bw.rawBucketsData) + if bw.rawData != nil { + op.RawData(*bw.rawData) } err := op.Execute(ctx) diff --git a/mongo/client.go b/mongo/client.go index 75b474ddf2..4ca2379333 100644 --- a/mongo/client.go +++ b/mongo/client.go @@ -956,7 +956,7 @@ func (c *Client) BulkWrite(ctx context.Context, writes []ClientBulkWrite, client: c, selector: selector, writeConcern: wc, - rawBucketsData: bwo.RawBucketsData, + rawData: bwo.RawData, } if bwo.VerboseResults == nil || !(*bwo.VerboseResults) { op.errorsOnly = true diff --git a/mongo/client_bulk_write.go b/mongo/client_bulk_write.go index 2873ebd985..7a0d557881 100644 --- a/mongo/client_bulk_write.go +++ b/mongo/client_bulk_write.go @@ -44,7 +44,7 @@ type clientBulkWrite struct { client *Client selector description.ServerSelector writeConcern *writeconcern.WriteConcern - rawBucketsData *bool + rawData *bool result ClientBulkWriteResult } @@ -145,8 +145,8 @@ func (bw *clientBulkWrite) newCommand() func([]byte, description.SelectedServer) dst = bsoncore.AppendDocumentElement(dst, "let", let) } // Set rawData for 8.2+ servers. - if bw.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *bw.rawBucketsData) + if bw.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *bw.rawData) } return dst, nil } diff --git a/mongo/collection.go b/mongo/collection.go index 3f74b9e7ed..8355845514 100644 --- a/mongo/collection.go +++ b/mongo/collection.go @@ -244,7 +244,7 @@ func (coll *Collection) BulkWrite(ctx context.Context, models []WriteModel, selector: selector, writeConcern: wc, let: args.Let, - rawBucketsData: args.RawBucketsData, + rawData: args.RawData, } err = op.execute(ctx) @@ -325,8 +325,8 @@ func (coll *Collection) insert( if args.Ordered != nil { op = op.Ordered(*args.Ordered) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } retry := driver.RetryNone if coll.client.retryWrites { @@ -379,8 +379,8 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{}, if args.Comment != nil { imOpts.SetComment(args.Comment) } - if args.RawBucketsData != nil { - imOpts = imOpts.SetRawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + imOpts = imOpts.SetRawData(*args.RawData) } res, err := coll.insert(ctx, []interface{}{document}, imOpts) @@ -541,8 +541,8 @@ func (coll *Collection) delete( } op = op.Let(let) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } // deleteMany cannot be retried @@ -581,11 +581,11 @@ func (coll *Collection) DeleteOne( return nil, fmt.Errorf("failed to construct options from builder: %w", err) } deleteOptions := &options.DeleteManyOptions{ - Collation: args.Collation, - Comment: args.Comment, - Hint: args.Hint, - Let: args.Let, - RawBucketsData: args.RawBucketsData, + Collation: args.Collation, + Comment: args.Comment, + Hint: args.Hint, + Let: args.Let, + RawData: args.RawData, } return coll.delete(ctx, filter, true, rrOne, deleteOptions) @@ -692,8 +692,8 @@ func (coll *Collection) updateOrReplace( } op = op.Comment(comment) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } retry := driver.RetryNone // retryable writes are only enabled updateOne/replaceOne operations @@ -789,7 +789,7 @@ func (coll *Collection) UpdateOne( Hint: args.Hint, Upsert: args.Upsert, Let: args.Let, - RawBucketsData: args.RawBucketsData, + RawData: args.RawData, } return coll.updateOrReplace(ctx, f, update, false, rrOne, true, args.Sort, updateOptions) @@ -880,7 +880,7 @@ func (coll *Collection) ReplaceOne( Hint: args.Hint, Let: args.Let, Comment: args.Comment, - RawBucketsData: args.RawBucketsData, + RawData: args.RawData, } return coll.updateOrReplace(ctx, f, r, false, rrOne, false, args.Sort, updateOptions) @@ -1052,8 +1052,8 @@ func aggregate(a aggregateParams, opts ...options.Lister[options.AggregateOption } op.CustomOptions(customOptions) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } retry := driver.RetryNone @@ -1143,8 +1143,8 @@ func (coll *Collection) CountDocuments(ctx context.Context, filter interface{}, } op.Hint(hintVal) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } retry := driver.RetryNone if coll.client.retryReads { @@ -1227,8 +1227,8 @@ func (coll *Collection) EstimatedDocumentCount( } op = op.Comment(comment) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } retry := driver.RetryNone @@ -1319,8 +1319,8 @@ func (coll *Collection) Distinct( } op.Hint(hint) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } retry := driver.RetryNone if coll.client.retryReads { @@ -1525,8 +1525,8 @@ func (coll *Collection) find( } op.Sort(sort) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } retry := driver.RetryNone if coll.client.retryReads { @@ -1561,7 +1561,7 @@ func newFindArgsFromFindOneArgs(args *options.FindOneOptions) *options.FindOptio v.ShowRecordID = args.ShowRecordID v.Skip = args.Skip v.Sort = args.Sort - v.RawBucketsData = args.RawBucketsData + v.RawData = args.RawData } return v } @@ -1724,8 +1724,8 @@ func (coll *Collection) FindOneAndDelete( } op = op.Let(let) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } return coll.findAndModify(ctx, op) @@ -1824,8 +1824,8 @@ func (coll *Collection) FindOneAndReplace( } op = op.Let(let) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } return coll.findAndModify(ctx, op) @@ -1936,8 +1936,8 @@ func (coll *Collection) FindOneAndUpdate( } op = op.Let(let) } - if args.RawBucketsData != nil { - op = op.RawBucketsData(*args.RawBucketsData) + if args.RawData != nil { + op = op.RawData(*args.RawData) } return coll.findAndModify(ctx, op) diff --git a/mongo/database.go b/mongo/database.go index 6aa1627187..7887d5f8c8 100644 --- a/mongo/database.go +++ b/mongo/database.go @@ -487,6 +487,9 @@ func (db *Database) ListCollections( if args.AuthorizedCollections != nil { op = op.AuthorizedCollections(*args.AuthorizedCollections) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } retry := driver.RetryNone if db.client.retryReads { diff --git a/mongo/index_view.go b/mongo/index_view.go index c92bb651be..d105fd4a27 100644 --- a/mongo/index_view.go +++ b/mongo/index_view.go @@ -101,6 +101,9 @@ func (iv IndexView) List(ctx context.Context, opts ...options.Lister[options.Lis op = op.BatchSize(*args.BatchSize) cursorOpts.BatchSize = *args.BatchSize } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } retry := driver.RetryNone if iv.coll.client.retryReads { @@ -279,6 +282,9 @@ func (iv IndexView) CreateMany( op.CommitQuorum(commitQuorum) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } _, err = processWriteError(op.Execute(ctx)) if err != nil { @@ -376,7 +382,12 @@ func (iv IndexView) createOptionsDoc(opts options.Lister[options.IndexOptions]) return optsDoc, nil } -func (iv IndexView) drop(ctx context.Context, index any, _ ...options.Lister[options.DropIndexesOptions]) error { +func (iv IndexView) drop(ctx context.Context, index any, opts ...options.Lister[options.DropIndexesOptions]) error { + args, err := mongoutil.NewOptions[options.DropIndexesOptions](opts...) + if err != nil { + return fmt.Errorf("failed to construct options from builder: %w", err) + } + if ctx == nil { ctx = context.Background() } @@ -387,7 +398,7 @@ func (iv IndexView) drop(ctx context.Context, index any, _ ...options.Lister[opt defer sess.EndSession() } - err := iv.coll.client.validSession(sess) + err = iv.coll.client.validSession(sess) if err != nil { return err } @@ -408,6 +419,10 @@ func (iv IndexView) drop(ctx context.Context, index any, _ ...options.Lister[opt Deployment(iv.coll.client.deployment).ServerAPI(iv.coll.client.serverAPI). Timeout(iv.coll.client.timeout).Crypt(iv.coll.client.cryptFLE).Authenticator(iv.coll.client.authenticator) + if args.RawData != nil { + op = op.RawData(*args.RawData) + } + err = op.Execute(ctx) if err != nil { return replaceErrors(err) diff --git a/mongo/options/aggregateoptions.go b/mongo/options/aggregateoptions.go index 1144275d59..5c1513c98a 100644 --- a/mongo/options/aggregateoptions.go +++ b/mongo/options/aggregateoptions.go @@ -26,7 +26,7 @@ type AggregateOptions struct { Hint interface{} Let interface{} Custom bson.M - RawBucketsData *bool + RawData *bool } // AggregateOptionsBuilder contains options to configure aggregate operations. @@ -165,11 +165,11 @@ func (ao *AggregateOptionsBuilder) SetCustom(c bson.M) *AggregateOptionsBuilder return ao } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (ao *AggregateOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *AggregateOptionsBuilder { +func (ao *AggregateOptionsBuilder) SetRawData(rawData bool) *AggregateOptionsBuilder { ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/bulkwriteoptions.go b/mongo/options/bulkwriteoptions.go index 98b74b5678..5d69d8f642 100644 --- a/mongo/options/bulkwriteoptions.go +++ b/mongo/options/bulkwriteoptions.go @@ -18,7 +18,7 @@ type BulkWriteOptions struct { Comment interface{} Ordered *bool Let interface{} - RawBucketsData *bool + RawData *bool } // BulkWriteOptionsBuilder contains options to configure bulk write operations. @@ -94,11 +94,11 @@ func (b *BulkWriteOptionsBuilder) SetLet(let interface{}) *BulkWriteOptionsBuild return b } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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) SetRawBucketsData(rawBucketsData bool) *BulkWriteOptionsBuilder { +func (b *BulkWriteOptionsBuilder) SetRawData(rawData bool) *BulkWriteOptionsBuilder { b.Opts = append(b.Opts, func(opts *BulkWriteOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/clientbulkwriteoptions.go b/mongo/options/clientbulkwriteoptions.go index 61fe02d66a..d79b41d482 100644 --- a/mongo/options/clientbulkwriteoptions.go +++ b/mongo/options/clientbulkwriteoptions.go @@ -19,7 +19,7 @@ type ClientBulkWriteOptions struct { Ordered *bool Let interface{} WriteConcern *writeconcern.WriteConcern - RawBucketsData *bool + RawData *bool VerboseResults *bool } @@ -109,11 +109,11 @@ func (b *ClientBulkWriteOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteCo return b } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 *ClientBulkWriteOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *ClientBulkWriteOptionsBuilder { +func (b *ClientBulkWriteOptionsBuilder) SetRawData(rawData bool) *ClientBulkWriteOptionsBuilder { b.Opts = append(b.Opts, func(opts *ClientBulkWriteOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/countoptions.go b/mongo/options/countoptions.go index 1485c8427c..ab16764529 100644 --- a/mongo/options/countoptions.go +++ b/mongo/options/countoptions.go @@ -11,12 +11,12 @@ package options // // See corresponding setter methods for documentation. type CountOptions struct { - Collation *Collation - Comment interface{} - Hint interface{} - Limit *int64 - Skip *int64 - RawBucketsData *bool + Collation *Collation + Comment interface{} + Hint interface{} + Limit *int64 + Skip *int64 + RawData *bool } // CountOptionsBuilder contains options to configure count operations. Each @@ -101,11 +101,11 @@ func (co *CountOptionsBuilder) SetSkip(i int64) *CountOptionsBuilder { return co } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (co *CountOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *CountOptionsBuilder { +func (co *CountOptionsBuilder) SetRawData(rawData bool) *CountOptionsBuilder { co.Opts = append(co.Opts, func(opts *CountOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/deleteoptions.go b/mongo/options/deleteoptions.go index 435b65739b..2034483a40 100644 --- a/mongo/options/deleteoptions.go +++ b/mongo/options/deleteoptions.go @@ -11,11 +11,11 @@ package options // // See corresponding setter methods for documentation. type DeleteOneOptions struct { - Collation *Collation - Comment interface{} - Hint interface{} - Let interface{} - RawBucketsData *bool + Collation *Collation + Comment interface{} + Hint interface{} + Let interface{} + RawData *bool } // DeleteOneOptionsBuilder contains options to configure DeleteOne operations. Each @@ -94,11 +94,11 @@ func (do *DeleteOneOptionsBuilder) SetLet(let interface{}) *DeleteOneOptionsBuil return do } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (do *DeleteOneOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *DeleteOneOptionsBuilder { +func (do *DeleteOneOptionsBuilder) SetRawData(rawData bool) *DeleteOneOptionsBuilder { do.Opts = append(do.Opts, func(opts *DeleteOneOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) @@ -111,11 +111,11 @@ func (do *DeleteOneOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *Delet // // See corresponding setter methods for documentation. type DeleteManyOptions struct { - Collation *Collation - Comment interface{} - Hint interface{} - Let interface{} - RawBucketsData *bool + Collation *Collation + Comment interface{} + Hint interface{} + Let interface{} + RawData *bool } // DeleteManyOptionsBuilder contains options to configure DeleteMany operations. @@ -194,11 +194,11 @@ func (do *DeleteManyOptionsBuilder) SetLet(let interface{}) *DeleteManyOptionsBu return do } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (do *DeleteManyOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *DeleteManyOptionsBuilder { +func (do *DeleteManyOptionsBuilder) SetRawData(rawData bool) *DeleteManyOptionsBuilder { do.Opts = append(do.Opts, func(opts *DeleteManyOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/distinctoptions.go b/mongo/options/distinctoptions.go index e264aef666..2ea2acf249 100644 --- a/mongo/options/distinctoptions.go +++ b/mongo/options/distinctoptions.go @@ -11,10 +11,10 @@ package options // // See corresponding setter methods for documentation. type DistinctOptions struct { - Collation *Collation - Comment interface{} - Hint interface{} - RawBucketsData *bool + Collation *Collation + Comment interface{} + Hint interface{} + RawData *bool } // DistinctOptionsBuilder contains options to configure distinct operations. Each @@ -79,11 +79,11 @@ func (do *DistinctOptionsBuilder) SetHint(hint interface{}) *DistinctOptionsBuil return do } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (do *DistinctOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *DistinctOptionsBuilder { +func (do *DistinctOptionsBuilder) SetRawData(rawData bool) *DistinctOptionsBuilder { do.Opts = append(do.Opts, func(opts *DistinctOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/estimatedcountoptions.go b/mongo/options/estimatedcountoptions.go index 01d698663d..e30ea42a85 100644 --- a/mongo/options/estimatedcountoptions.go +++ b/mongo/options/estimatedcountoptions.go @@ -11,8 +11,8 @@ package options // // See corresponding setter methods for documentation. type EstimatedDocumentCountOptions struct { - Comment interface{} - RawBucketsData *bool + Comment interface{} + RawData *bool } // EstimatedDocumentCountOptionsBuilder contains options to estimate document @@ -46,11 +46,11 @@ func (eco *EstimatedDocumentCountOptionsBuilder) SetComment(comment interface{}) return eco } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (eco *EstimatedDocumentCountOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *EstimatedDocumentCountOptionsBuilder { +func (eco *EstimatedDocumentCountOptionsBuilder) SetRawData(rawData bool) *EstimatedDocumentCountOptionsBuilder { eco.Opts = append(eco.Opts, func(opts *EstimatedDocumentCountOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/findoptions.go b/mongo/options/findoptions.go index 7cb6ebe263..ec2fd2bf65 100644 --- a/mongo/options/findoptions.go +++ b/mongo/options/findoptions.go @@ -35,7 +35,7 @@ type FindOptions struct { Let interface{} Limit *int64 NoCursorTimeout *bool - RawBucketsData *bool + RawData *bool } // FindOptionsBuilder represents functional options that configure an Findopts. @@ -269,11 +269,11 @@ func (f *FindOptionsBuilder) SetSort(sort interface{}) *FindOptionsBuilder { return f } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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) SetRawBucketsData(rawBucketsData bool) *FindOptionsBuilder { +func (f *FindOptionsBuilder) SetRawData(rawData bool) *FindOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) @@ -298,7 +298,7 @@ type FindOneOptions struct { ShowRecordID *bool Skip *int64 Sort interface{} - RawBucketsData *bool + RawData *bool } // FindOneOptionsBuilder represents functional options that configure an @@ -450,11 +450,11 @@ func (f *FindOneOptionsBuilder) SetSort(sort interface{}) *FindOneOptionsBuilder return f } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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) SetRawBucketsData(rawBucketsData bool) *FindOneOptionsBuilder { +func (f *FindOneOptionsBuilder) SetRawData(rawData bool) *FindOneOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) @@ -475,7 +475,7 @@ type FindOneAndReplaceOptions struct { Upsert *bool Hint interface{} Let interface{} - RawBucketsData *bool + RawData *bool } // FindOneAndReplaceOptionsBuilder contains options to perform a findAndModify @@ -622,11 +622,11 @@ func (f *FindOneAndReplaceOptionsBuilder) SetLet(let interface{}) *FindOneAndRep return f } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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) SetRawBucketsData(rawBucketsData bool) *FindOneAndReplaceOptionsBuilder { +func (f *FindOneAndReplaceOptionsBuilder) SetRawData(rawData bool) *FindOneAndReplaceOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneAndReplaceOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) @@ -649,7 +649,7 @@ type FindOneAndUpdateOptions struct { Upsert *bool Hint interface{} Let interface{} - RawBucketsData *bool + RawData *bool } // FindOneAndUpdateOptionsBuilder contains options to configure a @@ -810,11 +810,11 @@ func (f *FindOneAndUpdateOptionsBuilder) SetLet(let interface{}) *FindOneAndUpda return f } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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) SetRawBucketsData(rawBucketsData bool) *FindOneAndUpdateOptionsBuilder { +func (f *FindOneAndUpdateOptionsBuilder) SetRawData(rawData bool) *FindOneAndUpdateOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneAndUpdateOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) @@ -827,13 +827,13 @@ func (f *FindOneAndUpdateOptionsBuilder) SetRawBucketsData(rawBucketsData bool) // // See corresponding setter methods for documentation. type FindOneAndDeleteOptions struct { - Collation *Collation - Comment interface{} - Projection interface{} - Sort interface{} - Hint interface{} - Let interface{} - RawBucketsData *bool + Collation *Collation + Comment interface{} + Projection interface{} + Sort interface{} + Hint interface{} + Let interface{} + RawData *bool } // FindOneAndDeleteOptionsBuilder contains options to configure delete @@ -939,11 +939,11 @@ func (f *FindOneAndDeleteOptionsBuilder) SetLet(let interface{}) *FindOneAndDele return f } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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) SetRawBucketsData(rawBucketsData bool) *FindOneAndDeleteOptionsBuilder { +func (f *FindOneAndDeleteOptionsBuilder) SetRawData(rawData bool) *FindOneAndDeleteOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneAndDeleteOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/indexoptions.go b/mongo/options/indexoptions.go index b7b61c2edf..9030d2b530 100644 --- a/mongo/options/indexoptions.go +++ b/mongo/options/indexoptions.go @@ -12,6 +12,7 @@ package options // See corresponding setter methods for documentation. type CreateIndexesOptions struct { CommitQuorum interface{} + RawData *bool } // CreateIndexesOptionsBuilder contains options to create indexes. Each option @@ -119,9 +120,23 @@ func (c *CreateIndexesOptionsBuilder) SetCommitQuorumVotingMembers() *CreateInde return c } +// 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 (c *CreateIndexesOptionsBuilder) SetRawData(rawData bool) *CreateIndexesOptionsBuilder { + c.Opts = append(c.Opts, func(opts *CreateIndexesOptions) error { + opts.RawData = &rawData + + return nil + }) + + return c +} + // DropIndexesOptions represents arguments that can be used to configure // IndexView.DropOne and IndexView.DropAll operations. -type DropIndexesOptions struct{} +type DropIndexesOptions struct { + RawData *bool +} // DropIndexesOptionsBuilder contains options to configure dropping indexes. // Each option can be set through setter functions. See documentation for each @@ -140,12 +155,25 @@ func (d *DropIndexesOptionsBuilder) List() []func(*DropIndexesOptions) error { return d.Opts } +// 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 (d *DropIndexesOptionsBuilder) SetRawData(rawData bool) *DropIndexesOptionsBuilder { + d.Opts = append(d.Opts, func(opts *DropIndexesOptions) error { + opts.RawData = &rawData + + return nil + }) + + return d +} + // ListIndexesOptions represents arguments that can be used to configure an // IndexView.List operation. // // See corresponding setter methods for documentation. type ListIndexesOptions struct { BatchSize *int32 + RawData *bool } // ListIndexesOptionsBuilder contains options to configure count operations. Each @@ -177,6 +205,18 @@ func (l *ListIndexesOptionsBuilder) SetBatchSize(i int32) *ListIndexesOptionsBui return l } +// 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 (l *ListIndexesOptionsBuilder) SetRawData(rawData bool) *ListIndexesOptionsBuilder { + l.Opts = append(l.Opts, func(opts *ListIndexesOptions) error { + opts.RawData = &rawData + + return nil + }) + + return l +} + // IndexOptions represents arguments that can be used to configure a new index // created through the IndexView.CreateOne or IndexView.CreateMany operations. // diff --git a/mongo/options/insertoptions.go b/mongo/options/insertoptions.go index 3daf8d1267..de282f8628 100644 --- a/mongo/options/insertoptions.go +++ b/mongo/options/insertoptions.go @@ -13,7 +13,7 @@ package options type InsertOneOptions struct { BypassDocumentValidation *bool Comment interface{} - RawBucketsData *bool + RawData *bool } // InsertOneOptionsBuilder represents functional options that configure an @@ -54,11 +54,11 @@ func (ioo *InsertOneOptionsBuilder) SetComment(comment interface{}) *InsertOneOp return ioo } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (ioo *InsertOneOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *InsertOneOptionsBuilder { +func (ioo *InsertOneOptionsBuilder) SetRawData(rawData bool) *InsertOneOptionsBuilder { ioo.Opts = append(ioo.Opts, func(ioo *InsertOneOptions) error { - ioo.RawBucketsData = &rawBucketsData + ioo.RawData = &rawData return nil }) @@ -74,7 +74,7 @@ type InsertManyOptions struct { BypassDocumentValidation *bool Comment interface{} Ordered *bool - RawBucketsData *bool + RawData *bool } // InsertManyOptionsBuilder contains options to configure insert operations. @@ -136,11 +136,11 @@ func (imo *InsertManyOptionsBuilder) SetOrdered(b bool) *InsertManyOptionsBuilde return imo } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (imo *InsertManyOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *InsertManyOptionsBuilder { +func (imo *InsertManyOptionsBuilder) SetRawData(rawData bool) *InsertManyOptionsBuilder { imo.Opts = append(imo.Opts, func(opts *InsertManyOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/listcollectionsoptions.go b/mongo/options/listcollectionsoptions.go index 2106b2f906..d307a31bff 100644 --- a/mongo/options/listcollectionsoptions.go +++ b/mongo/options/listcollectionsoptions.go @@ -14,6 +14,7 @@ type ListCollectionsOptions struct { NameOnly *bool BatchSize *int32 AuthorizedCollections *bool + RawData *bool } // ListCollectionsOptionsBuilder contains options to configure list collection @@ -70,3 +71,15 @@ func (lc *ListCollectionsOptionsBuilder) SetAuthorizedCollections(b bool) *ListC return lc } + +// 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 (lc *ListCollectionsOptionsBuilder) SetRawData(rawData bool) *ListCollectionsOptionsBuilder { + lc.Opts = append(lc.Opts, func(opts *ListCollectionsOptions) error { + opts.RawData = &rawData + + return nil + }) + + return lc +} diff --git a/mongo/options/replaceoptions.go b/mongo/options/replaceoptions.go index 590bb7cf6f..53d399b52f 100644 --- a/mongo/options/replaceoptions.go +++ b/mongo/options/replaceoptions.go @@ -18,7 +18,7 @@ type ReplaceOptions struct { Upsert *bool Let interface{} Sort interface{} - RawBucketsData *bool + RawData *bool } // ReplaceOptionsBuilder contains options to configure replace operations. Each @@ -138,11 +138,11 @@ func (ro *ReplaceOptionsBuilder) SetSort(s interface{}) *ReplaceOptionsBuilder { return ro } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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) SetRawBucketsData(rawBucketsData bool) *ReplaceOptionsBuilder { +func (ro *ReplaceOptionsBuilder) SetRawData(rawData bool) *ReplaceOptionsBuilder { ro.Opts = append(ro.Opts, func(opts *ReplaceOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/mongo/options/updateoptions.go b/mongo/options/updateoptions.go index f81d634a1a..ab3a11a201 100644 --- a/mongo/options/updateoptions.go +++ b/mongo/options/updateoptions.go @@ -19,7 +19,7 @@ type UpdateOneOptions struct { Upsert *bool Let interface{} Sort interface{} - RawBucketsData *bool + RawData *bool } // UpdateOneOptionsBuilder contains options to configure UpdateOne operations. @@ -153,11 +153,11 @@ func (uo *UpdateOneOptionsBuilder) SetSort(s interface{}) *UpdateOneOptionsBuild return uo } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (uo *UpdateOneOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *UpdateOneOptionsBuilder { +func (uo *UpdateOneOptionsBuilder) SetRawData(rawData bool) *UpdateOneOptionsBuilder { uo.Opts = append(uo.Opts, func(opts *UpdateOneOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) @@ -177,7 +177,7 @@ type UpdateManyOptions struct { Hint interface{} Upsert *bool Let interface{} - RawBucketsData *bool + RawData *bool } // UpdateManyOptionsBuilder contains options to configure UpdateMany operations. @@ -296,11 +296,11 @@ func (uo *UpdateManyOptionsBuilder) SetLet(l interface{}) *UpdateManyOptionsBuil return uo } -// SetRawBucketsData sets the value for the RawBucketsData field. If true, it allows the CRUD operations to access timeseries +// 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 (uo *UpdateManyOptionsBuilder) SetRawBucketsData(rawBucketsData bool) *UpdateManyOptionsBuilder { +func (uo *UpdateManyOptionsBuilder) SetRawData(rawData bool) *UpdateManyOptionsBuilder { uo.Opts = append(uo.Opts, func(opts *UpdateManyOptions) error { - opts.RawBucketsData = &rawBucketsData + opts.RawData = &rawData return nil }) diff --git a/x/mongo/driver/operation/aggregate.go b/x/mongo/driver/operation/aggregate.go index aef778c0bf..380789ab04 100644 --- a/x/mongo/driver/operation/aggregate.go +++ b/x/mongo/driver/operation/aggregate.go @@ -50,7 +50,7 @@ type Aggregate struct { customOptions map[string]bsoncore.Value timeout *time.Duration omitMaxTimeMS bool - rawBucketsData *bool + rawData *bool result driver.CursorResponse } @@ -161,8 +161,8 @@ func (a *Aggregate) command(dst []byte, desc description.SelectedServer) ([]byte dst = bsoncore.AppendDocumentElement(dst, "let", a.let) } // Set rawData for 8.2+ servers. - if a.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *a.rawBucketsData) + if a.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *a.rawData) } for optionName, optionValue := range a.customOptions { dst = bsoncore.AppendValueElement(dst, optionName, optionValue) @@ -437,12 +437,12 @@ func (a *Aggregate) OmitMaxTimeMS(omit bool) *Aggregate { return a } -// RawBucketsData sets the rawData to access timeseries data in the compressed format. -func (a *Aggregate) RawBucketsData(rawBucketsData bool) *Aggregate { +// RawData sets the rawData to access timeseries data in the compressed format. +func (a *Aggregate) RawData(rawData bool) *Aggregate { if a == nil { a = new(Aggregate) } - a.rawBucketsData = &rawBucketsData + a.rawData = &rawData return a } diff --git a/x/mongo/driver/operation/count.go b/x/mongo/driver/operation/count.go index 6b57414e22..d056702aab 100644 --- a/x/mongo/driver/operation/count.go +++ b/x/mongo/driver/operation/count.go @@ -41,7 +41,7 @@ type Count struct { result CountResult serverAPI *driver.ServerAPIOptions timeout *time.Duration - rawBucketsData *bool + rawData *bool } // CountResult represents a count result returned by the server. @@ -149,8 +149,8 @@ func (c *Count) command(dst []byte, desc description.SelectedServer) ([]byte, er dst = bsoncore.AppendValueElement(dst, "comment", c.comment) } // Set rawData for 8.2+ servers. - if c.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *c.rawBucketsData) + if c.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *c.rawData) } return dst, nil } @@ -316,12 +316,12 @@ func (c *Count) Authenticator(authenticator driver.Authenticator) *Count { return c } -// RawBucketsData sets the rawData to access timeseries data in the compressed format. -func (c *Count) RawBucketsData(rawBucketsData bool) *Count { +// RawData sets the rawData to access timeseries data in the compressed format. +func (c *Count) RawData(rawData bool) *Count { if c == nil { c = new(Count) } - c.rawBucketsData = &rawBucketsData + c.rawData = &rawData return c } diff --git a/x/mongo/driver/operation/create_indexes.go b/x/mongo/driver/operation/create_indexes.go index 0380a55a26..17e88ba8c8 100644 --- a/x/mongo/driver/operation/create_indexes.go +++ b/x/mongo/driver/operation/create_indexes.go @@ -38,6 +38,7 @@ type CreateIndexes struct { result CreateIndexesResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool } // CreateIndexesResult represents a createIndexes result returned by the server. @@ -133,6 +134,10 @@ func (ci *CreateIndexes) command(dst []byte, desc description.SelectedServer) ([ if ci.indexes != nil { dst = bsoncore.AppendArrayElement(dst, "indexes", ci.indexes) } + // Set rawData for 8.2+ servers. + if ci.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *ci.rawData) + } return dst, nil } @@ -277,3 +282,13 @@ func (ci *CreateIndexes) Authenticator(authenticator driver.Authenticator) *Crea ci.authenticator = authenticator return ci } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (ci *CreateIndexes) RawData(rawData bool) *CreateIndexes { + if ci == nil { + ci = new(CreateIndexes) + } + + ci.rawData = &rawData + return ci +} diff --git a/x/mongo/driver/operation/delete.go b/x/mongo/driver/operation/delete.go index a0465845e1..e4510fb8fa 100644 --- a/x/mongo/driver/operation/delete.go +++ b/x/mongo/driver/operation/delete.go @@ -24,27 +24,27 @@ import ( // Delete performs a delete operation type Delete struct { - authenticator driver.Authenticator - comment bsoncore.Value - deletes []bsoncore.Document - ordered *bool - session *session.Client - clock *session.ClusterClock - collection string - monitor *event.CommandMonitor - crypt driver.Crypt - database string - deployment driver.Deployment - selector description.ServerSelector - writeConcern *writeconcern.WriteConcern - retry *driver.RetryMode - hint *bool - result DeleteResult - serverAPI *driver.ServerAPIOptions - let bsoncore.Document - timeout *time.Duration - rawBucketsData *bool - logger *logger.Logger + authenticator driver.Authenticator + comment bsoncore.Value + deletes []bsoncore.Document + ordered *bool + session *session.Client + clock *session.ClusterClock + collection string + monitor *event.CommandMonitor + crypt driver.Crypt + database string + deployment driver.Deployment + selector description.ServerSelector + writeConcern *writeconcern.WriteConcern + retry *driver.RetryMode + hint *bool + result DeleteResult + serverAPI *driver.ServerAPIOptions + let bsoncore.Document + timeout *time.Duration + rawData *bool + logger *logger.Logger } // DeleteResult represents a delete result returned by the server. @@ -141,8 +141,8 @@ func (d *Delete) command(dst []byte, desc description.SelectedServer) ([]byte, e dst = bsoncore.AppendDocumentElement(dst, "let", d.let) } // Set rawData for 8.2+ servers. - if d.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawBucketsData) + if d.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawData) } return dst, nil } @@ -343,12 +343,12 @@ func (d *Delete) Authenticator(authenticator driver.Authenticator) *Delete { return d } -// RawBucketsData sets the rawData to access timeseries data in the compressed format. -func (d *Delete) RawBucketsData(rawBucketsData bool) *Delete { +// RawData sets the rawData to access timeseries data in the compressed format. +func (d *Delete) RawData(rawData bool) *Delete { if d == nil { d = new(Delete) } - d.rawBucketsData = &rawBucketsData + d.rawData = &rawData return d } diff --git a/x/mongo/driver/operation/distinct.go b/x/mongo/driver/operation/distinct.go index b424ce801c..ef235e2475 100644 --- a/x/mongo/driver/operation/distinct.go +++ b/x/mongo/driver/operation/distinct.go @@ -43,7 +43,7 @@ type Distinct struct { result DistinctResult serverAPI *driver.ServerAPIOptions timeout *time.Duration - rawBucketsData *bool + rawData *bool } // DistinctResult represents a distinct result returned by the server. @@ -132,8 +132,8 @@ func (d *Distinct) command(dst []byte, desc description.SelectedServer) ([]byte, dst = bsoncore.AppendDocumentElement(dst, "query", d.query) } // Set rawData for 8.2+ servers. - if d.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawBucketsData) + if d.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawData) } return dst, nil } @@ -329,12 +329,12 @@ func (d *Distinct) Authenticator(authenticator driver.Authenticator) *Distinct { return d } -// RawBucketsData sets the rawData to access timeseries data in the compressed format. -func (d *Distinct) RawBucketsData(rawBucketsData bool) *Distinct { +// RawData sets the rawData to access timeseries data in the compressed format. +func (d *Distinct) RawData(rawData bool) *Distinct { if d == nil { d = new(Distinct) } - d.rawBucketsData = &rawBucketsData + d.rawData = &rawData return d } diff --git a/x/mongo/driver/operation/drop_indexes.go b/x/mongo/driver/operation/drop_indexes.go index e57cff72ee..14ecbdc1a9 100644 --- a/x/mongo/driver/operation/drop_indexes.go +++ b/x/mongo/driver/operation/drop_indexes.go @@ -37,6 +37,7 @@ type DropIndexes struct { result DropIndexesResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool } // DropIndexesResult represents a dropIndexes result returned by the server. @@ -104,7 +105,7 @@ func (di *DropIndexes) Execute(ctx context.Context) error { } -func (di *DropIndexes) command(dst []byte, _ description.SelectedServer) ([]byte, error) { +func (di *DropIndexes) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendStringElement(dst, "dropIndexes", di.collection) switch t := di.index.(type) { @@ -115,6 +116,10 @@ func (di *DropIndexes) command(dst []byte, _ description.SelectedServer) ([]byte dst = bsoncore.AppendDocumentElement(dst, "index", t) } } + // Set rawData for 8.2+ servers. + if di.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *di.rawData) + } return dst, nil } @@ -248,3 +253,13 @@ func (di *DropIndexes) Authenticator(authenticator driver.Authenticator) *DropIn di.authenticator = authenticator return di } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (di *DropIndexes) RawData(rawData bool) *DropIndexes { + if di == nil { + di = new(DropIndexes) + } + + di.rawData = &rawData + return di +} diff --git a/x/mongo/driver/operation/find.go b/x/mongo/driver/operation/find.go index 1f7d906d29..615e240850 100644 --- a/x/mongo/driver/operation/find.go +++ b/x/mongo/driver/operation/find.go @@ -61,7 +61,7 @@ type Find struct { result driver.CursorResponse serverAPI *driver.ServerAPIOptions timeout *time.Duration - rawBucketsData *bool + rawData *bool logger *logger.Logger omitMaxTimeMS bool } @@ -193,8 +193,8 @@ func (f *Find) command(dst []byte, desc description.SelectedServer) ([]byte, err dst = bsoncore.AppendBooleanElement(dst, "tailable", *f.tailable) } // Set rawData for 8.2+ servers. - if f.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *f.rawBucketsData) + if f.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *f.rawData) } return dst, nil } @@ -570,13 +570,13 @@ func (f *Find) Authenticator(authenticator driver.Authenticator) *Find { return f } -// RawBucketsData sets the rawData to access timeseries data in the compressed format. -func (f *Find) RawBucketsData(rawBucketsData bool) *Find { +// RawData sets the rawData to access timeseries data in the compressed format. +func (f *Find) RawData(rawData bool) *Find { if f == nil { f = new(Find) } - f.rawBucketsData = &rawBucketsData + f.rawData = &rawData return f } diff --git a/x/mongo/driver/operation/find_and_modify.go b/x/mongo/driver/operation/find_and_modify.go index bf01bb0745..2e524e78db 100644 --- a/x/mongo/driver/operation/find_and_modify.go +++ b/x/mongo/driver/operation/find_and_modify.go @@ -50,7 +50,7 @@ type FindAndModify struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration - rawBucketsData *bool + rawData *bool result FindAndModifyResult } @@ -213,8 +213,8 @@ func (fam *FindAndModify) command(dst []byte, desc description.SelectedServer) ( dst = bsoncore.AppendDocumentElement(dst, "let", fam.let) } // Set rawData for 8.2+ servers. - if fam.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *fam.rawBucketsData) + if fam.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *fam.rawData) } return dst, nil @@ -482,12 +482,12 @@ func (fam *FindAndModify) Authenticator(authenticator driver.Authenticator) *Fin return fam } -// RawBucketsData sets the rawData to access timeseries data in the compressed format. -func (fam *FindAndModify) RawBucketsData(rawBucketsData bool) *FindAndModify { +// RawData sets the rawData to access timeseries data in the compressed format. +func (fam *FindAndModify) RawData(rawData bool) *FindAndModify { if fam == nil { fam = new(FindAndModify) } - fam.rawBucketsData = &rawBucketsData + fam.rawData = &rawData return fam } diff --git a/x/mongo/driver/operation/insert.go b/x/mongo/driver/operation/insert.go index cdb479ff69..57d461ae3b 100644 --- a/x/mongo/driver/operation/insert.go +++ b/x/mongo/driver/operation/insert.go @@ -42,7 +42,7 @@ type Insert struct { result InsertResult serverAPI *driver.ServerAPIOptions timeout *time.Duration - rawBucketsData *bool + rawData *bool logger *logger.Logger } @@ -134,8 +134,8 @@ func (i *Insert) command(dst []byte, desc description.SelectedServer) ([]byte, e dst = bsoncore.AppendBooleanElement(dst, "ordered", *i.ordered) } // Set rawData for 8.2+ servers. - if i.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *i.rawBucketsData) + if i.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *i.rawData) } return dst, nil } @@ -324,12 +324,12 @@ func (i *Insert) Authenticator(authenticator driver.Authenticator) *Insert { return i } -// RawBucketsData sets the rawData to access timeseries data in the compressed format. -func (i *Insert) RawBucketsData(rawBucketsData bool) *Insert { +// RawData sets the rawData to access timeseries data in the compressed format. +func (i *Insert) RawData(rawData bool) *Insert { if i == nil { i = new(Insert) } - i.rawBucketsData = &rawBucketsData + i.rawData = &rawData return i } diff --git a/x/mongo/driver/operation/list_collections.go b/x/mongo/driver/operation/list_collections.go index 3f9b55a6c3..672404cb0b 100644 --- a/x/mongo/driver/operation/list_collections.go +++ b/x/mongo/driver/operation/list_collections.go @@ -39,6 +39,7 @@ type ListCollections struct { batchSize *int32 serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool } // NewListCollections constructs and returns a new ListCollections. @@ -92,7 +93,7 @@ func (lc *ListCollections) Execute(ctx context.Context) error { } -func (lc *ListCollections) command(dst []byte, _ description.SelectedServer) ([]byte, error) { +func (lc *ListCollections) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendInt32Element(dst, "listCollections", 1) if lc.filter != nil { dst = bsoncore.AppendDocumentElement(dst, "filter", lc.filter) @@ -110,6 +111,11 @@ func (lc *ListCollections) command(dst []byte, _ description.SelectedServer) ([] } dst = bsoncore.AppendDocumentElement(dst, "cursor", cursorDoc.Build()) + // Set rawData for 8.2+ servers. + if lc.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *lc.rawData) + } + return dst, nil } @@ -274,3 +280,13 @@ func (lc *ListCollections) Authenticator(authenticator driver.Authenticator) *Li lc.authenticator = authenticator return lc } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (lc *ListCollections) RawData(rawData bool) *ListCollections { + if lc == nil { + lc = new(ListCollections) + } + + lc.rawData = &rawData + return lc +} diff --git a/x/mongo/driver/operation/list_indexes.go b/x/mongo/driver/operation/list_indexes.go index d7642a19e1..21b138a40c 100644 --- a/x/mongo/driver/operation/list_indexes.go +++ b/x/mongo/driver/operation/list_indexes.go @@ -34,6 +34,7 @@ type ListIndexes struct { crypt driver.Crypt serverAPI *driver.ServerAPIOptions timeout *time.Duration + rawData *bool result driver.CursorResponse } @@ -91,16 +92,19 @@ func (li *ListIndexes) Execute(ctx context.Context) error { } -func (li *ListIndexes) command(dst []byte, _ description.SelectedServer) ([]byte, error) { +func (li *ListIndexes) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendStringElement(dst, "listIndexes", li.collection) cursorIdx, cursorDoc := bsoncore.AppendDocumentStart(nil) if li.batchSize != nil { - cursorDoc = bsoncore.AppendInt32Element(cursorDoc, "batchSize", *li.batchSize) } cursorDoc, _ = bsoncore.AppendDocumentEnd(cursorDoc, cursorIdx) dst = bsoncore.AppendDocumentElement(dst, "cursor", cursorDoc) + // Set rawData for 8.2+ servers. + if li.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *li.rawData) + } return dst, nil } @@ -235,3 +239,13 @@ func (li *ListIndexes) Authenticator(authenticator driver.Authenticator) *ListIn li.authenticator = authenticator return li } + +// RawData sets the rawData to access timeseries data in the compressed format. +func (li *ListIndexes) RawData(rawData bool) *ListIndexes { + if li == nil { + li = new(ListIndexes) + } + + li.rawData = &rawData + return li +} diff --git a/x/mongo/driver/operation/update.go b/x/mongo/driver/operation/update.go index b30badf465..9b06deef33 100644 --- a/x/mongo/driver/operation/update.go +++ b/x/mongo/driver/operation/update.go @@ -46,7 +46,7 @@ type Update struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration - rawBucketsData *bool + rawData *bool logger *logger.Logger } @@ -205,8 +205,8 @@ func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, e dst = bsoncore.AppendDocumentElement(dst, "let", u.let) } // Set rawData for 8.2+ servers. - if u.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawBucketsData) + if u.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawData) } return dst, nil @@ -428,12 +428,12 @@ func (u *Update) Authenticator(authenticator driver.Authenticator) *Update { return u } -// RawBucketsData sets the rawData to access timeseries data in the compressed format. -func (u *Update) RawBucketsData(rawBucketsData bool) *Update { +// RawData sets the rawData to access timeseries data in the compressed format. +func (u *Update) RawData(rawData bool) *Update { if u == nil { u = new(Update) } - u.rawBucketsData = &rawBucketsData + u.rawData = &rawData return u } From ae34fff98748ee1823c819c1b004edcd7b689bf9 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Thu, 3 Jul 2025 19:55:43 -0400 Subject: [PATCH 7/9] update specs --- testdata/specifications | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/specifications b/testdata/specifications index d6176ecbfb..0f8c6bd470 160000 --- a/testdata/specifications +++ b/testdata/specifications @@ -1 +1 @@ -Subproject commit d6176ecbfb5fbaa0e36619b72a873708b20bb20d +Subproject commit 0f8c6bd4703cceed8e6a05127236764d16e82650 From a74579b2b5f363b54281a52d05a6d94bf214bb3f Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Mon, 7 Jul 2025 15:49:25 -0400 Subject: [PATCH 8/9] update specs --- testdata/specifications | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/specifications b/testdata/specifications index 0f8c6bd470..0eab78b728 160000 --- a/testdata/specifications +++ b/testdata/specifications @@ -1 +1 @@ -Subproject commit 0f8c6bd4703cceed8e6a05127236764d16e82650 +Subproject commit 0eab78b728ef893fc6fc49129d6df86fb09aa21b From 93368c12c3087879cfeea5f48d9f2109d1aedb51 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Thu, 17 Jul 2025 10:19:51 -0400 Subject: [PATCH 9/9] update specs --- testdata/specifications | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/specifications b/testdata/specifications index 0eab78b728..42b4f9e85f 160000 --- a/testdata/specifications +++ b/testdata/specifications @@ -1 +1 @@ -Subproject commit 0eab78b728ef893fc6fc49129d6df86fb09aa21b +Subproject commit 42b4f9e85f50c981ab1da56bedb2c2bd91d2f533