return scope.Close(ThrowException(Exception::Error(String::New("Empty cursor"))));
}
assert(!(pos < 0 || pos >= rsz)); //m_pos correctly set by s_set_pos
- void *bsdata = TCLISTVALPTR(c->m_rs, pos);
+ const void *bsdata = TCLISTVALPTR(c->m_rs, pos);
assert(bsdata);
bson_iterator it;
+ bson_iterator_from_buffer(&it, (const char*) bsdata);
bson_type bt = bson_find_fieldpath_value2(*fpath, fpath.length(), &it);
if (bt == BSON_EOO) {
return scope.Close(Undefined());
});
};
-/*
-
module.exports.testQuery1 = function(test) {
test.ok(jb);
test.ok(jb.isOpen());
});
};
-*/
-
module.exports.testQuery2 = function(test) {
test.ok(jb);
test.ok(jb.isOpen());
{$orderby : {name : 1}},
function(err, cursor, count) {
test.ifError(err);
- console.log("count=" + count);
+ test.ok(cursor);
+ test.equal(2, count);
+ for (var c = 0; cursor.next(); ++c) {
+ var rv = cursor.object();
+ if (c != 0) continue;
+ test.equal(rv["name"], "Bounty");
+ test.equal(cursor.field("name"), "Bounty");
+ test.equal(rv["type"], "Cockatoo");
+ test.equal(cursor.field("type"), "Cockatoo");
+ test.equal(rv["male"], false);
+ test.equal(cursor.field("male"), false);
+ test.equal(rv["age"], 15);
+ test.equal(cursor.field("age"), 15);
+ test.equal("" + rv["birthdate"], "" + now);
+ test.equal("" + cursor.field("birthdate"), "" + now);
+ test.equal(rv["likes"].join(","), "sugar cane");
+ test.equal(cursor.field("likes").join(","), "sugar cane");
+ }
test.done();
});