File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,9 @@ pub enum CollectionType {
121121
122122 /// Indicates that the data store is a collection.
123123 Collection ,
124+
125+ /// Indicates that the data store is a timeseries.
126+ Timeseries ,
124127}
125128
126129/// Info about the collection that is contained in the `CollectionSpecification::info` field of a
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ mod index_management;
1515#[ cfg( all( not( feature = "sync" ) , not( feature = "tokio-sync" ) ) ) ]
1616mod lambda_examples;
1717pub mod spec;
18+ mod timeseries;
1819pub ( crate ) mod util;
1920
2021#[ cfg( feature = "in-use-encryption-unstable" ) ]
Original file line number Diff line number Diff line change 1+ use bson:: doc;
2+ use futures:: TryStreamExt ;
3+
4+ use crate :: {
5+ db:: options:: { CreateCollectionOptions , TimeseriesOptions } ,
6+ test:: log_uncaptured,
7+ Client ,
8+ } ;
9+
10+ use super :: LOCK ;
11+
12+ type Result < T > = anyhow:: Result < T > ;
13+
14+ #[ cfg_attr( feature = "tokio-runtime" , tokio:: test) ]
15+ #[ cfg_attr( feature = "async-std-runtime" , async_std:: test) ]
16+ async fn list_collections_timeseries ( ) -> Result < ( ) > {
17+ let _guard = LOCK . run_exclusively ( ) ;
18+
19+ let client = Client :: test_builder ( ) . build ( ) . await ;
20+ if client. server_version_lt ( 5 , 0 ) {
21+ log_uncaptured ( "Skipping list_collections_timeseries: timeseries require server >= 5.0" ) ;
22+ return Ok ( ( ) ) ;
23+ }
24+ let db = client. database ( "list_collections_timeseries" ) ;
25+ db. drop ( None ) . await ?;
26+ db. create_collection (
27+ "test" ,
28+ CreateCollectionOptions :: builder ( )
29+ . timeseries (
30+ TimeseriesOptions :: builder ( )
31+ . time_field ( "timestamp" . to_string ( ) )
32+ . meta_field ( None )
33+ . granularity ( None )
34+ . build ( ) ,
35+ )
36+ . build ( ) ,
37+ )
38+ . await ?;
39+ let results: Vec < _ > = db
40+ . list_collections ( doc ! { "name" : "test" } , None )
41+ . await ?
42+ . try_collect ( )
43+ . await ?;
44+ assert_eq ! ( results. len( ) , 1 ) ;
45+
46+ Ok ( ( ) )
47+ }
You can’t perform that action at this time.
0 commit comments