// Copyright (C) MongoDB, Inc. 2017-present. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this file except in compliance with the License. You may obtain // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 package options // DefaultIndexOptions represents the default options for a collection to apply on new indexes. This type can be used // when creating a new collection through the CreateCollectionOptions.SetDefaultIndexOptions method. type DefaultIndexOptions struct { // Specifies the storage engine to use for the index. The value must be a document in the form // {: }. The default value is nil, which means that the default storage engine // will be used. StorageEngine interface{} } // DefaultIndex creates a new DefaultIndexOptions instance. func DefaultIndex() *DefaultIndexOptions { return &DefaultIndexOptions{} } // SetStorageEngine sets the value for the StorageEngine field. func (d *DefaultIndexOptions) SetStorageEngine(storageEngine interface{}) *DefaultIndexOptions { d.StorageEngine = storageEngine return d } // TimeSeriesOptions specifies options on a time-series collection. type TimeSeriesOptions struct { // Name of the top-level field to be used for time. Inserted documents must have this field, // and the field must be of the BSON UTC datetime type (0x9). TimeField string // Optional name of the top-level field describing the series. This field is used to group // related data and may be of any BSON type, except for array. This name may not be the same // as the TimeField or _id. MetaField *string // Optional string specifying granularity of time-series data. Allowed granularity options are // "seconds", "minutes" and "hours". Granularity *string } // TimeSeries creates a new TimeSeriesOptions instance. func TimeSeries() *TimeSeriesOptions { return &TimeSeriesOptions{} } // SetTimeField sets the value for the TimeField. func (tso *TimeSeriesOptions) SetTimeField(timeField string) *TimeSeriesOptions { tso.TimeField = timeField return tso } // SetMetaField sets the value for the MetaField. func (tso *TimeSeriesOptions) SetMetaField(metaField string) *TimeSeriesOptions { tso.MetaField = &metaField return tso } // SetGranularity sets the value for Granularity. func (tso *TimeSeriesOptions) SetGranularity(granularity string) *TimeSeriesOptions { tso.Granularity = &granularity return tso } // CreateCollectionOptions represents options that can be used to configure a CreateCollection operation. type CreateCollectionOptions struct { // Specifies if the collection is capped (see https://www.mongodb.com/docs/manual/core/capped-collections/). If true, // the SizeInBytes option must also be specified. The default value is false. Capped *bool // Specifies the default collation for the new collection. This option is only valid for MongoDB versions >= 3.4. // For previous server versions, the driver will return an error if this option is used. The default value is nil. Collation *Collation // Specifies how change streams opened against the collection can return pre- and post-images of updated // documents. The value must be a document in the form {