Package com.mongodb.client.model
Class TimeSeriesOptions
- java.lang.Object
-
- com.mongodb.client.model.TimeSeriesOptions
-
public final class TimeSeriesOptions extends Object
Options related to the creation of time-series collections.- Since:
- 4.3
- See Also:
CreateCollectionOptions
- MongoDB documentation
- Time-series collections
-
-
Constructor Summary
Constructors Constructor Description TimeSeriesOptions(String timeField)
Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TimeSeriesGranularity
getGranularity()
Gets the granularity of the time-series data.String
getMetaField()
Gets the name of the meta field.String
getTimeField()
Gets the name of the field holding the time value.TimeSeriesOptions
granularity(TimeSeriesGranularity granularity)
Sets the granularity of the time-series data.TimeSeriesOptions
metaField(String metaField)
Sets the name of the meta field.String
toString()
-
-
-
Constructor Detail
-
TimeSeriesOptions
public TimeSeriesOptions(String timeField)
Construct a new instance.- Parameters:
timeField
- the name of the top-level field to be used for time. Inserted documents must have this field, and the field must be of the BSON datetime type.
-
-
Method Detail
-
getTimeField
public String getTimeField()
Gets the name of the field holding the time value.- Returns:
- the name of the field holding the time value.
-
getMetaField
@Nullable public String getMetaField()
Gets the name of the meta field.- Returns:
- the name of the meta field
- See Also:
metaField(String)
-
metaField
public TimeSeriesOptions metaField(@Nullable String metaField)
Sets the name of the meta field.The name of the field which contains metadata in each time series document. The metadata in the specified field should be data that is used to label a unique series of documents. The metadata should rarely, if ever, change. This field is used to group related data and may be of any BSON type, except for array. This name may not be the same as the
timeField
or "_id".- Parameters:
metaField
- the name of the meta field- Returns:
- this
- See Also:
getMetaField()
-
getGranularity
@Nullable public TimeSeriesGranularity getGranularity()
Gets the granularity of the time-series data.- Returns:
- the time-series granularity
- See Also:
granularity(TimeSeriesGranularity)
-
granularity
public TimeSeriesOptions granularity(@Nullable TimeSeriesGranularity granularity)
Sets the granularity of the time-series data.The default value is
TimeSeriesGranularity.SECONDS
.- Parameters:
granularity
- the time-series granularity- Returns:
- this
- See Also:
getGranularity()
-
-