public class CreateCollectionOperation extends Object implements AsyncWriteOperation<Void>, WriteOperation<Void>
Constructor and Description |
---|
CreateCollectionOperation(String databaseName,
String collectionName)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
CreateCollectionOperation |
autoIndex(boolean autoIndex)
Sets if _id field of the collection is indexed.
|
CreateCollectionOperation |
capped(boolean capped)
Sets whether the collection is capped.
|
Void |
execute(WriteBinding binding)
General execute which can return anything of type T
|
void |
executeAsync(AsyncWriteBinding binding,
SingleResultCallback<Void> callback)
General execute which can return anything of type T
|
String |
getCollectionName()
Gets the name of the collection to create.
|
long |
getMaxDocuments()
Gets the maximum number of documents allowed in the collection.
|
long |
getSizeInBytes()
Gets the maximum size of the collection in bytes.
|
BsonDocument |
getStorageEngineOptions()
Gets the storage engine options document for this collection.
|
boolean |
isAutoIndex()
The auto index value.
|
boolean |
isCapped()
Gets whether the collection is capped.
|
Boolean |
isUsePowerOf2Sizes()
Gets whether usePowerOf2Sizes should be used foe the allocation strategy.
|
CreateCollectionOperation |
maxDocuments(long maxDocuments)
Set the maximum number of documents in the collection.
|
CreateCollectionOperation |
sizeInBytes(long sizeInBytes)
Sets the maximum size of the collection in bytes.
|
CreateCollectionOperation |
storageEngineOptions(BsonDocument storageEngineOptions)
Sets the storage engine options document for this collection.
|
CreateCollectionOperation |
usePowerOf2Sizes(Boolean usePowerOf2Sizes)
Sets whether usePowerOf2Sizes should be used foe the allocation strategy.
|
public String getCollectionName()
public boolean isAutoIndex()
public CreateCollectionOperation autoIndex(boolean autoIndex)
autoIndex
- true if auto-index of _id is enabled. Only applies to capped collections.public long getMaxDocuments()
public CreateCollectionOperation maxDocuments(long maxDocuments)
maxDocuments
- the maximum number of documents in the collection. Only applies to capped collections.public boolean isCapped()
public CreateCollectionOperation capped(boolean capped)
sizeInBytes
.capped
- whether the collection is capped. Defaults to false.public long getSizeInBytes()
public CreateCollectionOperation sizeInBytes(long sizeInBytes)
sizeInBytes
- the maximum size of the collectionpublic Boolean isUsePowerOf2Sizes()
Note: usePowerOf2Sizes} became the default allocation strategy in mongodb 2.6
public CreateCollectionOperation usePowerOf2Sizes(Boolean usePowerOf2Sizes)
Note: usePowerOf2Sizes} became the default allocation strategy in mongodb 2.6
usePowerOf2Sizes
- as the default allocation strategypublic BsonDocument getStorageEngineOptions()
public CreateCollectionOperation storageEngineOptions(BsonDocument storageEngineOptions)
storageEngineOptions
- the storate engine optionspublic Void execute(WriteBinding binding)
WriteOperation
execute
in interface WriteOperation<Void>
binding
- the binding to execute in the context ofpublic void executeAsync(AsyncWriteBinding binding, SingleResultCallback<Void> callback)
AsyncWriteOperation
executeAsync
in interface AsyncWriteOperation<Void>
binding
- the binding to execute in the context ofcallback
- the callback to be called when the operation has been executed