Skip to content

Commit 56717a4

Browse files
authored
Fix failing snapshot example (#952)
1 parent 0e01f26 commit 56717a4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/mongocxx/mongodb.com/documentation_examples.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,11 +1319,11 @@ static bool is_snapshot_ready(mongocxx::client& client, mongocxx::collection& co
13191319

13201320
auto session = client.start_session(opts);
13211321
try {
1322-
auto cursor = collection.aggregate(session, {});
1323-
for (const auto& it : cursor) {
1324-
(void)it;
1325-
break;
1322+
auto maybe_value = collection.find_one(session, {});
1323+
if (maybe_value) {
1324+
return true;
13261325
}
1326+
return false;
13271327
} catch (const mongocxx::operation_exception& e) {
13281328
if (e.code().value() == 246) { // snapshot unavailable
13291329
return false;

0 commit comments

Comments
 (0)