mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-20 22:31:23 +01:00
Use type int for count
This commit is contained in:
parent
65c704ea90
commit
4c4ab51a2c
@ -45,7 +45,7 @@ public:
|
||||
virtual ~Database();
|
||||
/// Destructor
|
||||
|
||||
double count(Connection& connection, const std::string& collectionName) const;
|
||||
int count(Connection& connection, const std::string& collectionName) const;
|
||||
/// Sends a count request for the given collection to MongoDB. When
|
||||
/// the command fails, -1 is returned.
|
||||
|
||||
|
@ -32,7 +32,7 @@ Database::~Database()
|
||||
}
|
||||
|
||||
|
||||
double Database::count(Connection& connection, const std::string& collectionName) const
|
||||
int Database::count(Connection& connection, const std::string& collectionName) const
|
||||
{
|
||||
Poco::SharedPtr<Poco::MongoDB::QueryRequest> countRequest = createCountRequest(collectionName);
|
||||
|
||||
@ -42,7 +42,7 @@ double Database::count(Connection& connection, const std::string& collectionName
|
||||
if ( response.documents().size() > 0 )
|
||||
{
|
||||
Poco::MongoDB::Document::Ptr doc = response.documents()[0];
|
||||
return doc->get<double>("n");
|
||||
return doc->get<int>("n");
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -221,7 +221,8 @@ void MongoDBTest::testCountCommand()
|
||||
if ( response.documents().size() > 0 )
|
||||
{
|
||||
Poco::MongoDB::Document::Ptr doc = response.documents()[0];
|
||||
double count = doc->get<double>("n");
|
||||
std::cout << doc->toString() << std::endl;
|
||||
int count = doc->get<int>("n");
|
||||
assert(count == 1);
|
||||
}
|
||||
else
|
||||
@ -248,7 +249,7 @@ void MongoDBTest::testDBCountCommand()
|
||||
if ( response.documents().size() > 0 )
|
||||
{
|
||||
Poco::MongoDB::Document::Ptr doc = response.documents()[0];
|
||||
double count = doc->get<double>("n");
|
||||
int count = doc->get<int>("n");
|
||||
assert(count == 1);
|
||||
}
|
||||
else
|
||||
@ -267,7 +268,7 @@ void MongoDBTest::testDBCount2Command()
|
||||
}
|
||||
|
||||
Poco::MongoDB::Database db("team");
|
||||
double count = db.count(_mongo, "players");
|
||||
int count = db.count(_mongo, "players");
|
||||
assert(count == 1);
|
||||
}
|
||||
|
||||
@ -305,7 +306,8 @@ void MongoDBTest::testCursorRequest()
|
||||
}
|
||||
_mongo.sendRequest(*insertRequest);
|
||||
|
||||
double count = db.count(_mongo, "numbers");
|
||||
int count = db.count(_mongo, "numbers");
|
||||
std::cout << "count= " << count << std::endl;
|
||||
assert(count == 10000);
|
||||
|
||||
Poco::MongoDB::Cursor cursor("team", "numbers");
|
||||
@ -390,7 +392,7 @@ void MongoDBTest::testConnectionPool()
|
||||
if ( response.documents().size() > 0 )
|
||||
{
|
||||
Poco::MongoDB::Document::Ptr doc = response.documents()[0];
|
||||
double count = doc->get<double>("n");
|
||||
int count = doc->get<int>("n");
|
||||
assert(count == 1);
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user