Package com.mongodb.client.model
Class CreateCollectionOptions
java.lang.Object
com.mongodb.client.model.CreateCollectionOptions
Options for creating a collection
- Since:
- 3.0
- MongoDB documentation
- Create Collection
- Time-series collections
-
Constructor Summary
ConstructorDescriptionA shallow copy constructor. -
Method Summary
Modifier and TypeMethodDescriptioncapped
(boolean capped) sets whether the collection is capped.changeStreamPreAndPostImagesOptions
(ChangeStreamPreAndPostImagesOptions changeStreamPreAndPostImagesOptions) Sets the change stream pre- and post- images options.clusteredIndexOptions
(ClusteredIndexOptions clusteredIndexOptions) Sets the clustered index collection options.Sets the collation optionsencryptedFields
(Bson encryptedFields) Sets the encrypted fieldsexpireAfter
(long expireAfter, TimeUnit timeUnit) Sets the expire-after option.Gets change stream pre- and post- images options.Gets the clustered index collection options.Returns the collation optionsGets any explicitly set encrypted fields.long
getExpireAfter
(TimeUnit timeUnit) Returns the expire-after option.Gets the index option defaults for the collection.long
Gets the maximum number of documents allowed in a capped collection.long
Gets the maximum size in bytes of a capped collection.Gets the storage engine options document for the collection.Gets the time series collection options.Gets the validation options for documents being inserted or updated in a collectionindexOptionDefaults
(IndexOptionDefaults indexOptionDefaults) Sets the index option defaults for the collection.boolean
isCapped()
Gets whether the collection is capped.maxDocuments
(long maxDocuments) Sets the maximum number of documents allowed in a capped collection.sizeInBytes
(long sizeInBytes) Gets the maximum size of in bytes of a capped collection.storageEngineOptions
(Bson storageEngineOptions) Sets the storage engine options document defaults for the collectiontimeSeriesOptions
(TimeSeriesOptions timeSeriesOptions) Sets the time-series collection options.toString()
validationOptions
(ValidationOptions validationOptions) Sets the validation options for documents being inserted or updated in a collection
-
Constructor Details
-
CreateCollectionOptions
public CreateCollectionOptions() -
CreateCollectionOptions
A shallow copy constructor.- Parameters:
options
- The options to copy.- Since:
- 4.9
-
-
Method Details
-
getMaxDocuments
public long getMaxDocuments()Gets the maximum number of documents allowed in a capped collection.- Returns:
- max number of documents in a capped collection
-
maxDocuments
Sets the maximum number of documents allowed in a capped collection.- Parameters:
maxDocuments
- the maximum number of documents allowed in capped collection- Returns:
- this
-
isCapped
public boolean isCapped()Gets whether the collection is capped.- Returns:
- whether the collection is capped
-
capped
sets whether the collection is capped.- Parameters:
capped
- whether the collection is capped- Returns:
- this
-
getSizeInBytes
public long getSizeInBytes()Gets the maximum size in bytes of a capped collection.- Returns:
- the maximum size of a capped collection.
-
sizeInBytes
Gets the maximum size of in bytes of a capped collection.- Parameters:
sizeInBytes
- the maximum size of a capped collection.- Returns:
- this
-
getStorageEngineOptions
Gets the storage engine options document for the collection.- Returns:
- the storage engine options
- Since server release
- 3.0
-
storageEngineOptions
Sets the storage engine options document defaults for the collection- Parameters:
storageEngineOptions
- the storage engine options- Returns:
- this
- Since server release
- 3.0
-
getIndexOptionDefaults
Gets the index option defaults for the collection.- Returns:
- the index option defaults
- Since:
- 3.2
- Since server release
- 3.2
-
indexOptionDefaults
Sets the index option defaults for the collection.- Parameters:
indexOptionDefaults
- the index option defaults- Returns:
- this
- Since:
- 3.2
- Since server release
- 3.2
-
getValidationOptions
Gets the validation options for documents being inserted or updated in a collection- Returns:
- the validation options
- Since:
- 3.2
- Since server release
- 3.2
-
validationOptions
Sets the validation options for documents being inserted or updated in a collection- Parameters:
validationOptions
- the validation options- Returns:
- this
- Since:
- 3.2
- Since server release
- 3.2
-
getCollation
Returns the collation options- Returns:
- the collation options
- Since:
- 3.4
- Since server release
- 3.4
-
collation
Sets the collation optionsA null value represents the server default.
- Parameters:
collation
- the collation options to use- Returns:
- this
- Since:
- 3.4
- Since server release
- 3.4
-
getExpireAfter
Returns the expire-after option. The default value is 0, which indicates no expiration.- Parameters:
timeUnit
- the time unit- Returns:
- the expire-after option, which may be null.
- Since:
- 4.3
- MongoDB documentation
- Time-series collections
-
expireAfter
Sets the expire-after option.A duration indicating after how long old time-series data should be deleted. Partial seconds are ignored.
Currently applies only to time-series collections, so if this value is set then so must the time-series options
- Parameters:
expireAfter
- the expire-after duration. After conversion to seconds usingTimeUnit.convert(long, java.util.concurrent.TimeUnit)
, the value must be >= 0. A value of 0 indicates no expiration.timeUnit
- the time unit- Returns:
- this
- Since:
- 4.3
- See Also:
- MongoDB documentation
- Time-series collections
-
getTimeSeriesOptions
Gets the time series collection options.- Returns:
- the options for a time-series collection
- Since:
- 4.3
- MongoDB documentation
- Time-series collections
-
timeSeriesOptions
Sets the time-series collection options.- Parameters:
timeSeriesOptions
- the time-series options- Returns:
- this
- Since:
- 4.3
- MongoDB documentation
- Time-series collections
-
getClusteredIndexOptions
Gets the clustered index collection options.- Returns:
- the options for a clustered index
- Since:
- 4.7
-
clusteredIndexOptions
Sets the clustered index collection options.- Parameters:
clusteredIndexOptions
- the clustered index options- Returns:
- this
- Since:
- 4.7
-
getChangeStreamPreAndPostImagesOptions
Gets change stream pre- and post- images options.- Returns:
- the options for change stream pre- and post- images
- Since:
- 4.7
-
changeStreamPreAndPostImagesOptions
public CreateCollectionOptions changeStreamPreAndPostImagesOptions(ChangeStreamPreAndPostImagesOptions changeStreamPreAndPostImagesOptions) Sets the change stream pre- and post- images options.- Parameters:
changeStreamPreAndPostImagesOptions
- the change stream pre- and post- images options- Returns:
- this
- Since:
- 4.7
-
getEncryptedFields
Gets any explicitly set encrypted fields.Note: If not set the driver will lookup the namespace in
AutoEncryptionSettings.getEncryptedFieldsMap()
- Returns:
- the encrypted fields document
- Since:
- 4.7
- Since server release
- 6.0
-
encryptedFields
Sets the encrypted fieldsExplicitly set encrypted fields.
Note: If not set the driver will lookup the namespace in
AutoEncryptionSettings.getEncryptedFieldsMap()
- Parameters:
encryptedFields
- the encrypted fields document- Returns:
- this
- Since:
- 4.7
- MongoDB documentation
- In-use encryption
- Since server release
- 6.0
-
toString
-