Struct mungos::options::CreateCollectionOptions
source · [−]#[non_exhaustive]pub struct CreateCollectionOptions {Show 16 fields
pub capped: Option<bool>,
pub size: Option<u64>,
pub max: Option<u64>,
pub storage_engine: Option<Document>,
pub validator: Option<Document>,
pub validation_level: Option<ValidationLevel>,
pub validation_action: Option<ValidationAction>,
pub view_on: Option<String>,
pub pipeline: Option<Vec<Document, Global>>,
pub collation: Option<Collation>,
pub write_concern: Option<WriteConcern>,
pub index_option_defaults: Option<IndexOptionDefaults>,
pub timeseries: Option<TimeseriesOptions>,
pub expire_after_seconds: Option<Duration>,
pub change_stream_pre_and_post_images: Option<ChangeStreamPreAndPostImages>,
pub clustered_index: Option<ClusteredIndex>,
}
Expand description
These are the valid options for creating a collection with
Database::create_collection
.
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.capped: Option<bool>
Whether the collection should be capped. If true, size
must also be set.
size: Option<u64>
The maximum size (in bytes) for a capped collection. This option is ignored if capped
is
not set to true.
max: Option<u64>
The maximum number of documents in a capped collection. The size
limit takes precedence
over this option. If a capped collection reaches the size limit before it reaches the
maximum number of documents, MongoDB removes old documents.
storage_engine: Option<Document>
The storage engine that the collection should use. The value should take the following form:
{ <storage-engine-name>: <options> }
validator: Option<Document>
Specifies a validator to restrict the schema of documents which can exist in the
collection. Expressions can be specified using any query operators except $near
,
$nearSphere
, $text
, and $where
.
validation_level: Option<ValidationLevel>
Specifies how strictly the database should apply the validation rules to existing documents during an update.
validation_action: Option<ValidationAction>
Specifies whether the database should return an error or simply raise a warning if inserted documents do not pass the validation.
view_on: Option<String>
The name of the source collection or view to base this view on. If specified, this will cause a view to be created rather than a collection.
pipeline: Option<Vec<Document, Global>>
An array that consists of the aggregation pipeline stages to run against view_on
to
determine the contents of the view.
collation: Option<Collation>
The default collation for the collection or view.
write_concern: Option<WriteConcern>
The write concern for the operation.
index_option_defaults: Option<IndexOptionDefaults>
The default configuration for indexes created on this collection, including the _id index.
timeseries: Option<TimeseriesOptions>
An object containing options for creating time series collections. See the create
command documentation for
supported options, and the Time Series Collections documentation for more information.
This feature is only available on server versions 5.0 and above.
expire_after_seconds: Option<Duration>
Used to automatically delete documents in time series collections. See the create
command documentation for more
information.
change_stream_pre_and_post_images: Option<ChangeStreamPreAndPostImages>
Options for supporting change stream pre- and post-images.
clustered_index: Option<ClusteredIndex>
Options for clustered collections.
Implementations
sourceimpl CreateCollectionOptions
impl CreateCollectionOptions
sourcepub fn builder(
) -> CreateCollectionOptionsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder(
) -> CreateCollectionOptionsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building CreateCollectionOptions
.
On the builder, call .capped(...)
(optional), .size(...)
(optional), .max(...)
(optional), .storage_engine(...)
(optional), .validator(...)
(optional), .validation_level(...)
(optional), .validation_action(...)
(optional), .view_on(...)
(optional), .pipeline(...)
(optional), .collation(...)
(optional), .write_concern(...)
(optional), .index_option_defaults(...)
(optional), .timeseries(...)
(optional), .expire_after_seconds(...)
(optional), .change_stream_pre_and_post_images(...)
(optional), .clustered_index(...)
(optional) to set the values of the fields.
Finally, call .build()
to create the instance of CreateCollectionOptions
.
Trait Implementations
sourceimpl Clone for CreateCollectionOptions
impl Clone for CreateCollectionOptions
sourcefn clone(&self) -> CreateCollectionOptions
fn clone(&self) -> CreateCollectionOptions
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more