The following C++ code written using mongocxx returns a cursor.
bsoncxx::document::value filter = make_document(...some document...);
auto cursor {coll.find(filter.view())}; // coll is the collection object
How can I count the returned documents? Because cursor does NOT have a .count() method.
I also don't see a count/size method in the cursor class. It has
begin/enditerators, so it's technically possible to call std::distance(begin, end), but that's going to be utterly slow (linear complexity since it's going to loop through all the elements until reaching end()) and it's going to exhaust the cursor (it will point toend()once executed). So not a good idea.Wouldn't you be able to just use count_documents() using the same filter?