Package com.mongodb.client.model
Class CreateCollectionOptions
- java.lang.Object
-
- com.mongodb.client.model.CreateCollectionOptions
-
public class CreateCollectionOptions extends Object
Options for creating a collection- Since:
- 3.0
- MongoDB documentation
- Create Collection
-
-
Constructor Summary
Constructors Constructor Description CreateCollectionOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CreateCollectionOptions
autoIndex(boolean autoIndex)
Deprecated.this option was deprecated in MongoDB 3.2 and removed in MongodB 4.0CreateCollectionOptions
capped(boolean capped)
sets whether the collection is capped.CreateCollectionOptions
collation(Collation collation)
Sets the collation optionsCollation
getCollation()
Returns the collation optionsIndexOptionDefaults
getIndexOptionDefaults()
Gets the index option defaults for the collection.long
getMaxDocuments()
Gets the maximum number of documents allowed in a capped collection.long
getSizeInBytes()
Gets the maximum size in bytes of a capped collection.Bson
getStorageEngineOptions()
Gets the storage engine options document for the collection.ValidationOptions
getValidationOptions()
Gets the validation options for documents being inserted or updated in a collectionCreateCollectionOptions
indexOptionDefaults(IndexOptionDefaults indexOptionDefaults)
Sets the index option defaults for the collection.boolean
isAutoIndex()
Deprecated.this option was deprecated in MongoDB 3.2 and removed in MongodB 4.0boolean
isCapped()
Gets whether the collection is capped.Boolean
isUsePowerOf2Sizes()
Deprecated.As of MongoDB 3.0, power of 2 sizes is ignored by the MongoDB serverCreateCollectionOptions
maxDocuments(long maxDocuments)
Sets the maximum number of documents allowed in a capped collection.CreateCollectionOptions
sizeInBytes(long sizeInBytes)
Gets the maximum size of in bytes of a capped collection.CreateCollectionOptions
storageEngineOptions(Bson storageEngineOptions)
Sets the storage engine options document defaults for the collectionString
toString()
CreateCollectionOptions
usePowerOf2Sizes(Boolean usePowerOf2Sizes)
Deprecated.As of MongoDB 3.0, power of 2 sizes is ignored by the MongoDB serverCreateCollectionOptions
validationOptions(ValidationOptions validationOptions)
Sets the validation options for documents being inserted or updated in a collection
-
-
-
Method Detail
-
isAutoIndex
@Deprecated public boolean isAutoIndex()
Deprecated.this option was deprecated in MongoDB 3.2 and removed in MongodB 4.0Gets if auto-index is enabled- Returns:
- true if auto-index is enabled
-
autoIndex
@Deprecated public CreateCollectionOptions autoIndex(boolean autoIndex)
Deprecated.this option was deprecated in MongoDB 3.2 and removed in MongodB 4.0Gets if auto-index is to be enabled on the collection- Parameters:
autoIndex
- true if auto-index is enabled- Returns:
- this
-
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
public CreateCollectionOptions maxDocuments(long 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
public CreateCollectionOptions capped(boolean 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
public CreateCollectionOptions sizeInBytes(long sizeInBytes)
Gets the maximum size of in bytes of a capped collection.- Parameters:
sizeInBytes
- the maximum size of a capped collection.- Returns:
- this
-
isUsePowerOf2Sizes
@Deprecated @Nullable public Boolean isUsePowerOf2Sizes()
Deprecated.As of MongoDB 3.0, power of 2 sizes is ignored by the MongoDB serverGets whether the usePowerOf2Sizes allocation strategy is turned on for this collection.- Returns:
- true if the usePowerOf2Sizes allocation strategy is turned on for this collection
- MongoDB documentation
- usePowerOf2Sizes
- Since server release
- 2.6
-
usePowerOf2Sizes
@Deprecated public CreateCollectionOptions usePowerOf2Sizes(@Nullable Boolean usePowerOf2Sizes)
Deprecated.As of MongoDB 3.0, power of 2 sizes is ignored by the MongoDB serverSets whether the usePowerOf2Sizes allocation strategy is turned on for this collection.- Parameters:
usePowerOf2Sizes
- true if the usePowerOf2Sizes allocation strategy is turned on for this collection- Returns:
- this
- MongoDB documentation
- usePowerOf2Sizes
- Since server release
- 2.6
-
getStorageEngineOptions
@Nullable public Bson getStorageEngineOptions()
Gets the storage engine options document for the collection.- Returns:
- the storage engine options
- Since server release
- 3.0
-
storageEngineOptions
public CreateCollectionOptions storageEngineOptions(@Nullable Bson 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
public IndexOptionDefaults getIndexOptionDefaults()
Gets the index option defaults for the collection.- Returns:
- the index option defaults
- Since:
- 3.2
- Since server release
- 3.2
-
indexOptionDefaults
public CreateCollectionOptions indexOptionDefaults(IndexOptionDefaults 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
public ValidationOptions 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
public CreateCollectionOptions validationOptions(ValidationOptions 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
@Nullable public Collation getCollation()
Returns the collation options- Returns:
- the collation options
- Since:
- 3.4
- Since server release
- 3.4
-
collation
public CreateCollectionOptions collation(@Nullable Collation 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
-
-