librethinkdbxx
librethinkdbxx copied to clipboard
.changes() works, but limit(n).changes doesn't
The following code correctly streams results from a changes feed
static auto handle = std::async(std::launch::async, [](){
try {
std::unique_ptr<RethinkDB::Connection> conn = RethinkDB::connect("172.17.10.61", 28015);
RethinkDB::Cursor cursor = RethinkDB::table("leaderboard").changes().run(*conn);
for (auto score = cursor.begin(); score != cursor.end(); ++score) {
printf("%s\n", RethinkDB::write_datum(*score).c_str());
}
} catch (RethinkDB::Error &err) {
printf("%s\n", err.message.c_str());
}
});
However adding a limit (which would need an order_by, but see #10 ) gives no more results.
static auto handle = std::async(std::launch::async, [](){
try {
std::unique_ptr<RethinkDB::Connection> conn = RethinkDB::connect("172.17.10.61", 28015);
RethinkDB::Cursor cursor = RethinkDB::table("leaderboard").limit(2).changes().run(*conn);
for (auto score = cursor.begin(); score != cursor.end(); ++score) {
printf("%s\n", RethinkDB::write_datum(*score).c_str());
}
} catch (RethinkDB::Error &err) {
printf("%s\n", err.message.c_str());
}
});
That query is invalid and should throw an error. I got the following error when I tested your code:
Cannot get changes on the first elements of an unordered stream.
It just gives zero results, no error was thrown