enh(MongoDB): Document::get returns value by const reference instead of creating a copy and few other minor improvements.

This commit is contained in:
Matej Kenda
2024-05-23 09:32:57 +02:00
parent 4552df2f2e
commit cf1a29908a
10 changed files with 34 additions and 37 deletions

View File

@@ -60,7 +60,7 @@ void MongoDBTest::testOpCmdUUID()
Document::Ptr doc = response.documents()[0];
try
{
std::string name = doc->get<std::string>("name");
const auto& name = doc->get<std::string>("name");
assertEquals ("Barcelona", name );
Binary::Ptr uuidBinary = doc->get<Binary::Ptr>("uuid");
@@ -194,14 +194,14 @@ void MongoDBTest::testOpCmdFind()
try
{
std::string lastname = doc->get<std::string>("lastname");
const auto& lastname = doc->get<std::string>("lastname");
assertEquals ("Braem", lastname);
std::string firstname = doc->get<std::string>("firstname");
const auto& firstname = doc->get<std::string>("firstname");
assertEquals ("Franky", firstname);
Poco::Timestamp birthDateTimestamp = doc->get<Poco::Timestamp>("birthdate");
const auto& birthDateTimestamp = doc->get<Poco::Timestamp>("birthdate");
Poco::DateTime birthDate(birthDateTimestamp);
assertTrue (birthDate.year() == 1969 && birthDate.month() == 3 && birthDate.day() == 9);
Poco::Timestamp lastupdatedTimestamp = doc->get<Poco::Timestamp>("lastupdated");
const auto& lastupdatedTimestamp = doc->get<Poco::Timestamp>("lastupdated");
assertTrue (doc->isType<NullValue>("unknown"));
bool active = doc->get<bool>("active");
assertEquals (false, active);