use of com.mongodb.client.model.TimeSeriesGranularity in project mongo-java-driver by mongodb.
the class CreateCollectionOperation method getCommand.
private BsonDocument getCommand(final ConnectionDescription description) {
BsonDocument document = new BsonDocument("create", new BsonString(collectionName));
putIfFalse(document, "autoIndexId", autoIndex);
document.put("capped", BsonBoolean.valueOf(capped));
if (capped) {
putIfNotZero(document, "size", sizeInBytes);
putIfNotZero(document, "max", maxDocuments);
}
if (storageEngineOptions != null) {
document.put("storageEngine", storageEngineOptions);
}
if (indexOptionDefaults != null) {
document.put("indexOptionDefaults", indexOptionDefaults);
}
if (validator != null) {
document.put("validator", validator);
}
if (validationLevel != null) {
document.put("validationLevel", new BsonString(validationLevel.getValue()));
}
if (validationAction != null) {
document.put("validationAction", new BsonString(validationAction.getValue()));
}
appendWriteConcernToCommand(writeConcern, document, description);
if (collation != null) {
document.put("collation", collation.asDocument());
}
putIfNotZero(document, "expireAfterSeconds", expireAfterSeconds);
if (timeSeriesOptions != null) {
BsonDocument timeSeriesDocument = new BsonDocument("timeField", new BsonString(timeSeriesOptions.getTimeField()));
String metaField = timeSeriesOptions.getMetaField();
if (metaField != null) {
timeSeriesDocument.put("metaField", new BsonString(metaField));
}
TimeSeriesGranularity granularity = timeSeriesOptions.getGranularity();
if (granularity != null) {
timeSeriesDocument.put("granularity", new BsonString(getGranularityAsString(granularity)));
}
document.put("timeseries", timeSeriesDocument);
}
return document;
}
Aggregations