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/client_operation_execution.go b/internal/integration/unified/client_operation_execution.go index 75948ff8a0..9e7ab88e5f 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.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 c3e7040256..3744707e0c 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.SetRawData(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.SetRawData(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.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized countDocuments option %q", key) } @@ -225,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 { @@ -279,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) } @@ -291,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 } @@ -433,6 +443,8 @@ func executeDeleteOne(ctx context.Context, operation *operation) (*operationResu opts.SetHint(hint) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized deleteOne option %q", key) } @@ -487,6 +499,8 @@ func executeDeleteMany(ctx context.Context, operation *operation) (*operationRes opts.SetHint(hint) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized deleteMany option %q", key) } @@ -545,6 +559,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.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized distinct option %q", key) } @@ -593,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) } @@ -690,6 +708,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.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized estimatedDocumentCount option %q", key) } @@ -842,6 +862,8 @@ func executeFindOneAndDelete(ctx context.Context, operation *operation) (*operat opts.SetSort(val.Document()) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndDelete option %q", key) } @@ -924,6 +946,8 @@ func executeFindOneAndReplace(ctx context.Context, operation *operation) (*opera opts.SetSort(val.Document()) case "upsert": opts.SetUpsert(val.Boolean()) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndReplace option %q", key) } @@ -1016,6 +1040,8 @@ func executeFindOneAndUpdate(ctx context.Context, operation *operation) (*operat } case "upsert": opts.SetUpsert(val.Boolean()) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized findOneAndUpdate option %q", key) } @@ -1062,6 +1088,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.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized insertMany option %q", key) } @@ -1112,6 +1140,8 @@ func executeInsertOne(ctx context.Context, operation *operation) (*operationResu opts.SetBypassDocumentValidation(val.Boolean()) case "comment": opts.SetComment(val) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized insertOne option %q", key) } @@ -1156,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) } @@ -1302,6 +1334,8 @@ func executeReplaceOne(ctx context.Context, operation *operation) (*operationRes opts.SetUpsert(val.Boolean()) case "let": opts.SetLet(val.Document()) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized replaceOne option %q", key) } @@ -1500,6 +1534,8 @@ func createFindCursor(ctx context.Context, operation *operation) (*cursorResult, case "maxAwaitTimeMS": maxAwaitTimeMS := time.Duration(val.Int32()) * time.Millisecond opts.SetMaxAwaitTime(maxAwaitTimeMS) + case "rawData": + opts.SetRawData(val.Boolean()) default: return nil, fmt.Errorf("unrecognized find option %q", key) } diff --git a/internal/integration/unified/crud_helpers.go b/internal/integration/unified/crud_helpers.go index 34de29d683..aeda7ba0ec 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.SetRawData(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.SetRawData(val.Boolean()) default: return nil, nil, fmt.Errorf("unrecognized update option %q", key) } @@ -162,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 415a90ae55..7a3181c6c4 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{} + rawData *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.rawData != nil { + op.RawData(*bw.rawData) + } + 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.rawData != nil { + op.RawData(*bw.rawData) + } + 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.rawData != nil { + op.RawData(*bw.rawData) + } + err := op.Execute(ctx) return op.Result(), err diff --git a/mongo/client.go b/mongo/client.go index f3bf5ed5fb..4ca2379333 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, + 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 ca6ecf5240..7a0d557881 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 + rawData *bool result ClientBulkWriteResult } @@ -143,6 +144,10 @@ func (bw *clientBulkWrite) newCommand() func([]byte, description.SelectedServer) } dst = bsoncore.AppendDocumentElement(dst, "let", let) } + // Set rawData for 8.2+ servers. + 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 d7693c4245..8355845514 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, + rawData: args.RawData, } err = op.execute(ctx) @@ -324,6 +325,9 @@ func (coll *Collection) insert( if args.Ordered != nil { op = op.Ordered(*args.Ordered) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } 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.RawData != nil { + imOpts = imOpts.SetRawData(*args.RawData) + } 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.RawData != nil { + op = op.RawData(*args.RawData) + } // deleteMany cannot be retried retryMode := driver.RetryNone @@ -575,6 +585,7 @@ func (coll *Collection) DeleteOne( Comment: args.Comment, Hint: args.Hint, Let: args.Let, + RawData: args.RawData, } return coll.delete(ctx, filter, true, rrOne, deleteOptions) @@ -681,6 +692,9 @@ func (coll *Collection) updateOrReplace( } op = op.Comment(comment) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } retry := driver.RetryNone // retryable writes are only enabled updateOne/replaceOne operations if !multi && coll.client.retryWrites { @@ -775,6 +789,7 @@ func (coll *Collection) UpdateOne( Hint: args.Hint, Upsert: args.Upsert, Let: args.Let, + RawData: args.RawData, } return coll.updateOrReplace(ctx, f, update, false, rrOne, true, args.Sort, updateOptions) @@ -865,6 +880,7 @@ func (coll *Collection) ReplaceOne( Hint: args.Hint, Let: args.Let, Comment: args.Comment, + RawData: args.RawData, } return coll.updateOrReplace(ctx, f, r, false, rrOne, false, args.Sort, updateOptions) @@ -1036,6 +1052,9 @@ func aggregate(a aggregateParams, opts ...options.Lister[options.AggregateOption } op.CustomOptions(customOptions) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } 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.RawData != nil { + op = op.RawData(*args.RawData) + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1205,6 +1227,9 @@ func (coll *Collection) EstimatedDocumentCount( } op = op.Comment(comment) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } retry := driver.RetryNone if coll.client.retryReads { @@ -1294,6 +1319,9 @@ func (coll *Collection) Distinct( } op.Hint(hint) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1497,6 +1525,9 @@ func (coll *Collection) find( } op.Sort(sort) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } retry := driver.RetryNone if coll.client.retryReads { retry = driver.RetryOncePerCommand @@ -1530,6 +1561,7 @@ func newFindArgsFromFindOneArgs(args *options.FindOneOptions) *options.FindOptio v.ShowRecordID = args.ShowRecordID v.Skip = args.Skip v.Sort = args.Sort + v.RawData = args.RawData } return v } @@ -1692,6 +1724,9 @@ func (coll *Collection) FindOneAndDelete( } op = op.Let(let) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } return coll.findAndModify(ctx, op) } @@ -1789,6 +1824,9 @@ func (coll *Collection) FindOneAndReplace( } op = op.Let(let) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } return coll.findAndModify(ctx, op) } @@ -1898,6 +1936,9 @@ func (coll *Collection) FindOneAndUpdate( } op = op.Let(let) } + if args.RawData != nil { + op = op.RawData(*args.RawData) + } return coll.findAndModify(ctx, op) } 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 cf419677dc..5c1513c98a 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 + RawData *bool } // AggregateOptionsBuilder contains options to configure aggregate operations. @@ -163,3 +164,15 @@ func (ao *AggregateOptionsBuilder) SetCustom(c bson.M) *AggregateOptionsBuilder return ao } + +// 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) SetRawData(rawData bool) *AggregateOptionsBuilder { + ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error { + opts.RawData = &rawData + + return nil + }) + + return ao +} diff --git a/mongo/options/bulkwriteoptions.go b/mongo/options/bulkwriteoptions.go index 186e83a0c5..5d69d8f642 100644 --- a/mongo/options/bulkwriteoptions.go +++ b/mongo/options/bulkwriteoptions.go @@ -18,6 +18,7 @@ type BulkWriteOptions struct { Comment interface{} Ordered *bool Let interface{} + RawData *bool } // BulkWriteOptionsBuilder contains options to configure bulk write operations. @@ -92,3 +93,15 @@ func (b *BulkWriteOptionsBuilder) SetLet(let interface{}) *BulkWriteOptionsBuild return b } + +// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries +// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. +func (b *BulkWriteOptionsBuilder) SetRawData(rawData bool) *BulkWriteOptionsBuilder { + b.Opts = append(b.Opts, func(opts *BulkWriteOptions) error { + opts.RawData = &rawData + + return nil + }) + + return b +} diff --git a/mongo/options/clientbulkwriteoptions.go b/mongo/options/clientbulkwriteoptions.go index a55ac27f05..d79b41d482 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 + RawData *bool VerboseResults *bool } @@ -108,6 +109,18 @@ func (b *ClientBulkWriteOptionsBuilder) SetWriteConcern(wc *writeconcern.WriteCo return b } +// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries +// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. +func (b *ClientBulkWriteOptionsBuilder) SetRawData(rawData bool) *ClientBulkWriteOptionsBuilder { + b.Opts = append(b.Opts, func(opts *ClientBulkWriteOptions) error { + opts.RawData = &rawData + + 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..ab16764529 100644 --- a/mongo/options/countoptions.go +++ b/mongo/options/countoptions.go @@ -16,6 +16,7 @@ type CountOptions struct { Hint interface{} Limit *int64 Skip *int64 + RawData *bool } // CountOptionsBuilder contains options to configure count operations. Each @@ -99,3 +100,15 @@ func (co *CountOptionsBuilder) SetSkip(i int64) *CountOptionsBuilder { return co } + +// 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) SetRawData(rawData bool) *CountOptionsBuilder { + co.Opts = append(co.Opts, func(opts *CountOptions) error { + opts.RawData = &rawData + + return nil + }) + + return co +} diff --git a/mongo/options/deleteoptions.go b/mongo/options/deleteoptions.go index 1d045d9960..2034483a40 100644 --- a/mongo/options/deleteoptions.go +++ b/mongo/options/deleteoptions.go @@ -15,6 +15,7 @@ type DeleteOneOptions struct { Comment interface{} Hint interface{} Let interface{} + RawData *bool } // DeleteOneOptionsBuilder contains options to configure DeleteOne operations. Each @@ -93,6 +94,18 @@ func (do *DeleteOneOptionsBuilder) SetLet(let interface{}) *DeleteOneOptionsBuil return do } +// 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) SetRawData(rawData bool) *DeleteOneOptionsBuilder { + do.Opts = append(do.Opts, func(opts *DeleteOneOptions) error { + opts.RawData = &rawData + + return nil + }) + + return do +} + // DeleteManyOptions represents arguments that can be used to configure DeleteMany // operations. // @@ -102,6 +115,7 @@ type DeleteManyOptions struct { Comment interface{} Hint interface{} Let interface{} + RawData *bool } // DeleteManyOptionsBuilder contains options to configure DeleteMany operations. @@ -179,3 +193,15 @@ func (do *DeleteManyOptionsBuilder) SetLet(let interface{}) *DeleteManyOptionsBu return do } + +// 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) SetRawData(rawData bool) *DeleteManyOptionsBuilder { + do.Opts = append(do.Opts, func(opts *DeleteManyOptions) error { + opts.RawData = &rawData + + return nil + }) + + return do +} diff --git a/mongo/options/distinctoptions.go b/mongo/options/distinctoptions.go index 3449ecee36..2ea2acf249 100644 --- a/mongo/options/distinctoptions.go +++ b/mongo/options/distinctoptions.go @@ -14,6 +14,7 @@ type DistinctOptions struct { Collation *Collation Comment interface{} Hint interface{} + RawData *bool } // DistinctOptionsBuilder contains options to configure distinct operations. Each @@ -77,3 +78,15 @@ func (do *DistinctOptionsBuilder) SetHint(hint interface{}) *DistinctOptionsBuil return do } + +// 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) SetRawData(rawData bool) *DistinctOptionsBuilder { + do.Opts = append(do.Opts, func(opts *DistinctOptions) error { + opts.RawData = &rawData + + return nil + }) + + return do +} diff --git a/mongo/options/estimatedcountoptions.go b/mongo/options/estimatedcountoptions.go index 2bee45a8f6..e30ea42a85 100644 --- a/mongo/options/estimatedcountoptions.go +++ b/mongo/options/estimatedcountoptions.go @@ -12,6 +12,7 @@ package options // See corresponding setter methods for documentation. type EstimatedDocumentCountOptions struct { Comment interface{} + RawData *bool } // EstimatedDocumentCountOptionsBuilder contains options to estimate document @@ -44,3 +45,15 @@ func (eco *EstimatedDocumentCountOptionsBuilder) SetComment(comment interface{}) return eco } + +// 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) SetRawData(rawData bool) *EstimatedDocumentCountOptionsBuilder { + eco.Opts = append(eco.Opts, func(opts *EstimatedDocumentCountOptions) error { + opts.RawData = &rawData + + return nil + }) + + return eco +} diff --git a/mongo/options/findoptions.go b/mongo/options/findoptions.go index ea627900ea..ec2fd2bf65 100644 --- a/mongo/options/findoptions.go +++ b/mongo/options/findoptions.go @@ -35,6 +35,7 @@ type FindOptions struct { Let interface{} Limit *int64 NoCursorTimeout *bool + RawData *bool } // FindOptionsBuilder represents functional options that configure an Findopts. @@ -268,6 +269,18 @@ func (f *FindOptionsBuilder) SetSort(sort interface{}) *FindOptionsBuilder { return f } +// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries +// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. +func (f *FindOptionsBuilder) SetRawData(rawData bool) *FindOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOptions) error { + opts.RawData = &rawData + + return nil + }) + + return f +} + // FindOneOptions represents arguments that can be used to configure a FindOne // operation. // @@ -285,6 +298,7 @@ type FindOneOptions struct { ShowRecordID *bool Skip *int64 Sort interface{} + RawData *bool } // FindOneOptionsBuilder represents functional options that configure an @@ -436,6 +450,17 @@ func (f *FindOneOptionsBuilder) SetSort(sort interface{}) *FindOneOptionsBuilder return f } +// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries +// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. +func (f *FindOneOptionsBuilder) SetRawData(rawData bool) *FindOneOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOneOptions) error { + opts.RawData = &rawData + return nil + }) + + return f +} + // FindOneAndReplaceOptions represents arguments that can be used to configure a // FindOneAndReplace instance. // @@ -450,6 +475,7 @@ type FindOneAndReplaceOptions struct { Upsert *bool Hint interface{} Let interface{} + RawData *bool } // FindOneAndReplaceOptionsBuilder contains options to perform a findAndModify @@ -596,6 +622,18 @@ func (f *FindOneAndReplaceOptionsBuilder) SetLet(let interface{}) *FindOneAndRep return f } +// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries +// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. +func (f *FindOneAndReplaceOptionsBuilder) SetRawData(rawData bool) *FindOneAndReplaceOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOneAndReplaceOptions) error { + opts.RawData = &rawData + + return nil + }) + + return f +} + // FindOneAndUpdateOptions represents arguments that can be used to configure a // FindOneAndUpdate options. // @@ -611,6 +649,7 @@ type FindOneAndUpdateOptions struct { Upsert *bool Hint interface{} Let interface{} + RawData *bool } // FindOneAndUpdateOptionsBuilder contains options to configure a @@ -771,6 +810,18 @@ func (f *FindOneAndUpdateOptionsBuilder) SetLet(let interface{}) *FindOneAndUpda return f } +// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries +// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. +func (f *FindOneAndUpdateOptionsBuilder) SetRawData(rawData bool) *FindOneAndUpdateOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOneAndUpdateOptions) error { + opts.RawData = &rawData + + return nil + }) + + return f +} + // FindOneAndDeleteOptions represents arguments that can be used to configure a // FindOneAndDelete operation. // @@ -782,6 +833,7 @@ type FindOneAndDeleteOptions struct { Sort interface{} Hint interface{} Let interface{} + RawData *bool } // FindOneAndDeleteOptionsBuilder contains options to configure delete @@ -886,3 +938,15 @@ func (f *FindOneAndDeleteOptionsBuilder) SetLet(let interface{}) *FindOneAndDele return f } + +// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries +// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. +func (f *FindOneAndDeleteOptionsBuilder) SetRawData(rawData bool) *FindOneAndDeleteOptionsBuilder { + f.Opts = append(f.Opts, func(opts *FindOneAndDeleteOptions) error { + opts.RawData = &rawData + + return nil + }) + + return f +} 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 61745600a9..de282f8628 100644 --- a/mongo/options/insertoptions.go +++ b/mongo/options/insertoptions.go @@ -13,6 +13,7 @@ package options type InsertOneOptions struct { BypassDocumentValidation *bool Comment interface{} + RawData *bool } // InsertOneOptionsBuilder represents functional options that configure an @@ -53,6 +54,18 @@ func (ioo *InsertOneOptionsBuilder) SetComment(comment interface{}) *InsertOneOp return ioo } +// 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) SetRawData(rawData bool) *InsertOneOptionsBuilder { + ioo.Opts = append(ioo.Opts, func(ioo *InsertOneOptions) error { + ioo.RawData = &rawData + + 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 + RawData *bool } // InsertManyOptionsBuilder contains options to configure insert operations. @@ -121,3 +135,15 @@ func (imo *InsertManyOptionsBuilder) SetOrdered(b bool) *InsertManyOptionsBuilde return imo } + +// 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) SetRawData(rawData bool) *InsertManyOptionsBuilder { + imo.Opts = append(imo.Opts, func(opts *InsertManyOptions) error { + opts.RawData = &rawData + + return nil + }) + + return imo +} 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 32caceff16..53d399b52f 100644 --- a/mongo/options/replaceoptions.go +++ b/mongo/options/replaceoptions.go @@ -18,6 +18,7 @@ type ReplaceOptions struct { Upsert *bool Let interface{} Sort interface{} + RawData *bool } // ReplaceOptionsBuilder contains options to configure replace operations. Each @@ -136,3 +137,15 @@ func (ro *ReplaceOptionsBuilder) SetSort(s interface{}) *ReplaceOptionsBuilder { return ro } + +// SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries +// collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. +func (ro *ReplaceOptionsBuilder) SetRawData(rawData bool) *ReplaceOptionsBuilder { + ro.Opts = append(ro.Opts, func(opts *ReplaceOptions) error { + opts.RawData = &rawData + + return nil + }) + + return ro +} diff --git a/mongo/options/updateoptions.go b/mongo/options/updateoptions.go index f7b22e6f84..ab3a11a201 100644 --- a/mongo/options/updateoptions.go +++ b/mongo/options/updateoptions.go @@ -19,6 +19,7 @@ type UpdateOneOptions struct { Upsert *bool Let interface{} Sort interface{} + RawData *bool } // UpdateOneOptionsBuilder contains options to configure UpdateOne operations. @@ -152,6 +153,18 @@ func (uo *UpdateOneOptionsBuilder) SetSort(s interface{}) *UpdateOneOptionsBuild return uo } +// 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) SetRawData(rawData bool) *UpdateOneOptionsBuilder { + uo.Opts = append(uo.Opts, func(opts *UpdateOneOptions) error { + opts.RawData = &rawData + + 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{} + RawData *bool } // UpdateManyOptionsBuilder contains options to configure UpdateMany operations. @@ -281,3 +295,15 @@ func (uo *UpdateManyOptionsBuilder) SetLet(l interface{}) *UpdateManyOptionsBuil return uo } + +// 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) SetRawData(rawData bool) *UpdateManyOptionsBuilder { + uo.Opts = append(uo.Opts, func(opts *UpdateManyOptions) error { + opts.RawData = &rawData + + return nil + }) + + return uo +} diff --git a/testdata/specifications b/testdata/specifications index f4c0bbdbf8..0eab78b728 160000 --- a/testdata/specifications +++ b/testdata/specifications @@ -1 +1 @@ -Subproject commit f4c0bbdbf8a8560580c947ca2c331794431a0c78 +Subproject commit 0eab78b728ef893fc6fc49129d6df86fb09aa21b diff --git a/x/mongo/driver/operation/aggregate.go b/x/mongo/driver/operation/aggregate.go index a0cd5bd25e..380789ab04 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 + rawData *bool result driver.CursorResponse } @@ -159,6 +160,10 @@ func (a *Aggregate) command(dst []byte, desc description.SelectedServer) ([]byte if a.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", a.let) } + // Set rawData for 8.2+ servers. + 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) } @@ -431,3 +436,13 @@ func (a *Aggregate) OmitMaxTimeMS(omit bool) *Aggregate { a.omitMaxTimeMS = omit return a } + +// 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.rawData = &rawData + return a +} diff --git a/x/mongo/driver/operation/count.go b/x/mongo/driver/operation/count.go index 5ecaa3a936..d056702aab 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 + rawData *bool } // CountResult represents a count result returned by the server. @@ -139,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) @@ -147,6 +148,10 @@ func (c *Count) command(dst []byte, _ description.SelectedServer) ([]byte, error if c.comment.Type != bsoncore.Type(0) { dst = bsoncore.AppendValueElement(dst, "comment", c.comment) } + // Set rawData for 8.2+ servers. + if c.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *c.rawData) + } return dst, nil } @@ -310,3 +315,13 @@ func (c *Count) Authenticator(authenticator driver.Authenticator) *Count { c.authenticator = authenticator return c } + +// 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.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 e6f47042a8..e4510fb8fa 100644 --- a/x/mongo/driver/operation/delete.go +++ b/x/mongo/driver/operation/delete.go @@ -43,6 +43,7 @@ type Delete struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration + rawData *bool logger *logger.Logger } @@ -139,6 +140,10 @@ func (d *Delete) command(dst []byte, desc description.SelectedServer) ([]byte, e if d.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", d.let) } + // Set rawData for 8.2+ servers. + if d.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawData) + } return dst, nil } @@ -337,3 +342,13 @@ func (d *Delete) Authenticator(authenticator driver.Authenticator) *Delete { d.authenticator = authenticator return d } + +// 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.rawData = &rawData + return d +} diff --git a/x/mongo/driver/operation/distinct.go b/x/mongo/driver/operation/distinct.go index 89d412def3..ef235e2475 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 + rawData *bool } // DistinctResult represents a distinct result returned by the server. @@ -130,6 +131,10 @@ func (d *Distinct) command(dst []byte, desc description.SelectedServer) ([]byte, if d.query != nil { dst = bsoncore.AppendDocumentElement(dst, "query", d.query) } + // Set rawData for 8.2+ servers. + if d.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawData) + } return dst, nil } @@ -323,3 +328,13 @@ func (d *Distinct) Authenticator(authenticator driver.Authenticator) *Distinct { d.authenticator = authenticator return d } + +// 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.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 b607cb14d7..615e240850 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 + rawData *bool logger *logger.Logger omitMaxTimeMS bool } @@ -191,6 +192,10 @@ func (f *Find) command(dst []byte, desc description.SelectedServer) ([]byte, err if f.tailable != nil { dst = bsoncore.AppendBooleanElement(dst, "tailable", *f.tailable) } + // Set rawData for 8.2+ servers. + if f.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *f.rawData) + } return dst, nil } @@ -565,6 +570,16 @@ func (f *Find) Authenticator(authenticator driver.Authenticator) *Find { return f } +// 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.rawData = &rawData + 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..2e524e78db 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 + rawData *bool result FindAndModifyResult } @@ -211,6 +212,10 @@ func (fam *FindAndModify) command(dst []byte, desc description.SelectedServer) ( if fam.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", fam.let) } + // Set rawData for 8.2+ servers. + if fam.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *fam.rawData) + } return dst, nil } @@ -476,3 +481,13 @@ func (fam *FindAndModify) Authenticator(authenticator driver.Authenticator) *Fin fam.authenticator = authenticator return fam } + +// 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.rawData = &rawData + return fam +} diff --git a/x/mongo/driver/operation/insert.go b/x/mongo/driver/operation/insert.go index b48e2c85f3..57d461ae3b 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 + rawData *bool logger *logger.Logger } @@ -132,6 +133,10 @@ func (i *Insert) command(dst []byte, desc description.SelectedServer) ([]byte, e if i.ordered != nil { dst = bsoncore.AppendBooleanElement(dst, "ordered", *i.ordered) } + // Set rawData for 8.2+ servers. + if i.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *i.rawData) + } return dst, nil } @@ -318,3 +323,13 @@ func (i *Insert) Authenticator(authenticator driver.Authenticator) *Insert { i.authenticator = authenticator return i } + +// 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.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 722c06ef94..9b06deef33 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 + rawData *bool logger *logger.Logger } @@ -203,6 +204,10 @@ func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, e if u.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", u.let) } + // Set rawData for 8.2+ servers. + if u.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawData) + } return dst, nil } @@ -422,3 +427,13 @@ func (u *Update) Authenticator(authenticator driver.Authenticator) *Update { u.authenticator = authenticator return u } + +// 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.rawData = &rawData + return u +}