$orderby must be -1 or 1. The latest MongoDB release throws an error when using 0.

This commit is contained in:
fbraem
2015-05-14 18:36:18 +02:00
parent 732ae1c75a
commit 7cfd70d56f

View File

@@ -234,7 +234,7 @@ void sample5(Poco::MongoDB::Connection& connection)
// When orderby is needed, use 2 separate documents in the query selector
cursor.query().selector().addNewDocument("$query").add("birthyear", 1987);
cursor.query().selector().addNewDocument("$orderby").add("lastname", 0);
cursor.query().selector().addNewDocument("$orderby").add("lastname", -1);
Poco::MongoDB::ResponseMessage& response = cursor.next(connection);
while(1)
@@ -410,7 +410,7 @@ void sample11(Poco::MongoDB::Connection& connection)
if ( response.hasDocuments() )
{
std::cout << "Count: " << response.documents()[0]->get<double>("n") << std::endl;
std::cout << "Count: " << response.documents()[0]->get<int>("n") << std::endl;
}
}