Polishing.
Rename Granularities/Granularity to Granularity and GranularityDefinition to proivide a more natural wording towards using predefined granularities. Validate presence of referenced properties through the TimeSeries annotation. Tweak Javadoc, reformat code, add unit tests. See #3731 Original pull request: #3732.
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
[[time-series]]
|
||||
== Time Series
|
||||
|
||||
MongoDB 5.0 introduced https://docs.mongodb.com/manual/core/timeseries-collections/[Time Series] collections optimized to efficiently store sequences of measurements.
|
||||
Those collections need to be actively created before inserting any data. This can be done by manually executing the command, defining time series collection options or extracting options from a `@TimeSeries` annotation as shown in the examples below.
|
||||
MongoDB 5.0 introduced https://docs.mongodb.com/manual/core/timeseries-collections/[Time Series] collections that are optimized to efficiently store documents over time such as measurements or events.
|
||||
Those collections need to be created as such before inserting any data.
|
||||
Collections can be created by either running the `createCollection` command, defining time series collection options or extracting options from a `@TimeSeries` annotation as shown in the examples below.
|
||||
|
||||
.Create a Time Series Collection
|
||||
====
|
||||
.Create a Time Series via the MongoDB Driver
|
||||
[code, java]
|
||||
[code,java]
|
||||
----
|
||||
template.execute(db -> {
|
||||
|
||||
@@ -19,14 +20,14 @@ template.execute(db -> {
|
||||
});
|
||||
----
|
||||
|
||||
.Create a Time Series Collection with CollectionOptions
|
||||
[code, java]
|
||||
.Create a Time Series Collection with `CollectionOptions`
|
||||
[code,java]
|
||||
----
|
||||
template.createCollection("weather", CollectionOptions.timeSeries("timestamp"));
|
||||
----
|
||||
|
||||
.Create a Time Series Collection derived from an Annotation
|
||||
[code, java]
|
||||
[code,java]
|
||||
----
|
||||
@TimeSeries(collection="weather", timeField = "timestamp")
|
||||
public class Measurement {
|
||||
@@ -41,5 +42,5 @@ template.createCollection(Measurement.class);
|
||||
====
|
||||
|
||||
The snippets above can easily be transferred to the reactive API offering the very same methods.
|
||||
Just make sure to _subscribe_.
|
||||
Make sure to properly _subscribe_ to the returned publishers.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user