Skip to content

Commit 5da6823

Browse files
committed
RUST-795 Update versioned api connection examples
1 parent 6826e0c commit 5da6823

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

src/test/documentation_examples.rs

+15-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tokio::sync::RwLockReadGuard;
55
use crate::{
66
bson::{doc, Bson},
77
error::Result,
8-
options::{ClientOptions, CursorType, FindOptions, ServerApi, ServerApiVersion},
8+
options::{ClientOptions, FindOptions, ServerApi, ServerApiVersion},
99
test::{TestClient, DEFAULT_URI, LOCK},
1010
Client,
1111
Collection,
@@ -1377,47 +1377,42 @@ async fn versioned_api_examples() -> Result<()> {
13771377
}
13781378

13791379
let uri = DEFAULT_URI.clone();
1380-
// Start 1. Declare an API version on a client
1380+
// Start Versioned API Example 1
13811381
let mut options = ClientOptions::parse(&uri).await?;
13821382
let server_api = ServerApi::builder().version(ServerApiVersion::V1).build();
13831383
options.server_api = Some(server_api);
13841384
let client = Client::with_options(options)?;
1385-
let cursor = client
1386-
.database("versioned_api_example")
1387-
.collection::<Document>("example")
1388-
.find(None, None)
1389-
.await?;
1390-
// End 1.
1385+
// End Versioned API Example 1
13911386

1392-
// Start 2. Strict option
1387+
// Start Versioned API Example 2
13931388
let mut options = ClientOptions::parse(&uri).await?;
13941389
let server_api = ServerApi::builder()
13951390
.version(ServerApiVersion::V1)
13961391
.strict(true)
13971392
.build();
13981393
options.server_api = Some(server_api);
13991394
let client = Client::with_options(options)?;
1395+
// End Versioned API Example 2
14001396

1401-
let find_options = FindOptions::builder()
1402-
.cursor_type(CursorType::Tailable)
1397+
// Start Versioned API Example 3
1398+
let mut options = ClientOptions::parse(&uri).await?;
1399+
let server_api = ServerApi::builder()
1400+
.version(ServerApiVersion::V1)
1401+
.strict(false)
14031402
.build();
1404-
let cursor = client
1405-
.database("versioned_api_example")
1406-
.collection::<Document>("example")
1407-
.find(None, find_options)
1408-
.await
1409-
.expect_err("should fail");
1410-
// End 2.
1403+
options.server_api = Some(server_api);
1404+
let client = Client::with_options(options)?;
1405+
// End Versioned API Example 3
14111406

1412-
// Start 3. deprecationErrors option
1407+
// Start Versioned API Example 4
14131408
let mut options = ClientOptions::parse(&uri).await?;
14141409
let server_api = ServerApi::builder()
14151410
.version(ServerApiVersion::V1)
14161411
.deprecation_errors(true)
14171412
.build();
14181413
options.server_api = Some(server_api);
14191414
let client = Client::with_options(options)?;
1420-
// End 3.
1415+
// End Versioned API Example 4
14211416

14221417
Ok(())
14231418
}

0 commit comments

Comments
 (0)