use of com.mongodb.client.model.IndexOptionDefaults in project mongo-java-driver by mongodb.
the class MongoDatabaseImpl method executeCreateCollection.
private void executeCreateCollection(@Nullable final ClientSession clientSession, final String collectionName, final CreateCollectionOptions createCollectionOptions) {
CreateCollectionOperation operation = new CreateCollectionOperation(name, collectionName, writeConcern).collation(createCollectionOptions.getCollation()).capped(createCollectionOptions.isCapped()).sizeInBytes(createCollectionOptions.getSizeInBytes()).maxDocuments(createCollectionOptions.getMaxDocuments()).storageEngineOptions(toBsonDocument(createCollectionOptions.getStorageEngineOptions())).expireAfter(createCollectionOptions.getExpireAfter(TimeUnit.SECONDS)).timeSeriesOptions(createCollectionOptions.getTimeSeriesOptions());
IndexOptionDefaults indexOptionDefaults = createCollectionOptions.getIndexOptionDefaults();
Bson storageEngine = indexOptionDefaults.getStorageEngine();
if (storageEngine != null) {
operation.indexOptionDefaults(new BsonDocument("storageEngine", toBsonDocument(storageEngine)));
}
ValidationOptions validationOptions = createCollectionOptions.getValidationOptions();
Bson validator = validationOptions.getValidator();
if (validator != null) {
operation.validator(toBsonDocument(validator));
}
if (validationOptions.getValidationLevel() != null) {
operation.validationLevel(validationOptions.getValidationLevel());
}
if (validationOptions.getValidationAction() != null) {
operation.validationAction(validationOptions.getValidationAction());
}
executor.execute(operation, readConcern, clientSession);
}
Aggregations