public class CreateCollectionOperation extends java.lang.Object implements AsyncWriteOperation<java.lang.Void>, WriteOperation<java.lang.Void>
Constructor and Description |
---|
CreateCollectionOperation(java.lang.String databaseName,
java.lang.String collectionName)
Construct a new instance.
|
CreateCollectionOperation(java.lang.String databaseName,
java.lang.String collectionName,
WriteConcern writeConcern)
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.
|
CreateCollectionOperation |
collation(Collation collation)
Sets the collation options
|
java.lang.Void |
execute(WriteBinding binding)
General execute which can return anything of type T
|
void |
executeAsync(AsyncWriteBinding binding,
SingleResultCallback<java.lang.Void> callback)
General execute which can return anything of type T
|
Collation |
getCollation()
Returns the collation options
|
java.lang.String |
getCollectionName()
Gets the name of the collection to create.
|
BsonDocument |
getIndexOptionDefaults()
Gets the index option defaults for the collection.
|
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.
|
ValidationAction |
getValidationAction()
Gets the
ValidationAction . |
ValidationLevel |
getValidationLevel()
Gets the
ValidationLevel that determines how strictly MongoDB applies the validation rules to existing documents during an
insert or update. |
BsonDocument |
getValidator()
Gets the validation rules for inserting or updating documents
|
WriteConcern |
getWriteConcern()
Gets the write concern.
|
CreateCollectionOperation |
indexOptionDefaults(BsonDocument indexOptionDefaults)
Sets the index option defaults document for the collection.
|
boolean |
isAutoIndex()
The auto index value.
|
boolean |
isCapped()
Gets whether the collection is capped.
|
java.lang.Boolean |
isUsePowerOf2Sizes()
Deprecated.
As of MongoDB 3.0, power of 2 sizes is ignored by the MongoDB server
|
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(java.lang.Boolean usePowerOf2Sizes)
Deprecated.
As of MongoDB 3.0, power of 2 sizes is ignored by the MongoDB server
|
CreateCollectionOperation |
validationAction(ValidationAction validationAction)
Sets the
ValidationAction that determines whether to error on invalid documents or just warn about the violations but allow
invalid documents. |
CreateCollectionOperation |
validationLevel(ValidationLevel validationLevel)
Sets the validation level that determines how strictly MongoDB applies the validation rules to existing documents during an insert
or update.
|
CreateCollectionOperation |
validator(BsonDocument validator)
Sets the validation rules for inserting or updating documents
|
public CreateCollectionOperation(java.lang.String databaseName, java.lang.String collectionName)
databaseName
- the name of the database for the operation.collectionName
- the name of the collection to be created.public CreateCollectionOperation(java.lang.String databaseName, java.lang.String collectionName, WriteConcern writeConcern)
databaseName
- the name of the database for the operation.collectionName
- the name of the collection to be created.writeConcern
- the write concernpublic java.lang.String getCollectionName()
public WriteConcern getWriteConcern()
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 collection@Deprecated public java.lang.Boolean isUsePowerOf2Sizes()
Note: usePowerOf2Sizes} became the default allocation strategy in mongodb 2.6
@Deprecated public CreateCollectionOperation usePowerOf2Sizes(java.lang.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 storage engine optionspublic BsonDocument getIndexOptionDefaults()
public CreateCollectionOperation indexOptionDefaults(BsonDocument indexOptionDefaults)
indexOptionDefaults
- the index option defaultspublic BsonDocument getValidator()
public CreateCollectionOperation validator(BsonDocument validator)
validator
- the validation rules for inserting or updating documentspublic ValidationLevel getValidationLevel()
ValidationLevel
that determines how strictly MongoDB applies the validation rules to existing documents during an
insert or update.public CreateCollectionOperation validationLevel(ValidationLevel validationLevel)
validationLevel
- the validation levelpublic ValidationAction getValidationAction()
ValidationAction
.public CreateCollectionOperation validationAction(ValidationAction validationAction)
ValidationAction
that determines whether to error on invalid documents or just warn about the violations but allow
invalid documents.validationAction
- the validation actionpublic Collation getCollation()
public CreateCollectionOperation collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic java.lang.Void execute(WriteBinding binding)
WriteOperation
execute
in interface WriteOperation<java.lang.Void>
binding
- the binding to execute in the context ofpublic void executeAsync(AsyncWriteBinding binding, SingleResultCallback<java.lang.Void> callback)
AsyncWriteOperation
executeAsync
in interface AsyncWriteOperation<java.lang.Void>
binding
- the binding to execute in the context ofcallback
- the callback to be called when the operation has been executed