From: adam Date: Fri, 2 Nov 2012 17:05:55 +0000 (+0700) Subject: #1 X-Git-Tag: v1.2.12~643^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6bdfc2855024b9e1eb27eede85711867e139592f;p=platform%2Fupstream%2Fejdb.git #1 --- diff --git a/node/ejdb.js b/node/ejdb.js index dec707b..50b9769 100644 --- a/node/ejdb.js +++ b/node/ejdb.js @@ -67,6 +67,10 @@ EJDB.prototype.save = function(cname, jsarr, cb) { }); }; +EJDB.prototype.load = function(cname, oid, cb) { + return this._impl.load(cname, oid, cb); +}; + module.exports = EJDB; diff --git a/node/ejdb_native.cc b/node/ejdb_native.cc index b2b0fab..f84a566 100644 --- a/node/ejdb_native.cc +++ b/node/ejdb_native.cc @@ -127,7 +127,7 @@ namespace ejdb { } case BSON_STRING: case BSON_SYMBOL: - return scope.Close(String::New(bson_iterator_string(it), bson_iterator_string_len(it))); + return scope.Close(String::New(bson_iterator_string(it), bson_iterator_string_len(it) - 1)); case BSON_NULL: return scope.Close(Null()); case BSON_UNDEFINED: @@ -207,10 +207,10 @@ namespace ejdb { case BSON_SYMBOL: if (obt == BSON_ARRAY) { ret->Set(knum, - String::New(bson_iterator_string(it), bson_iterator_string_len(it))); + String::New(bson_iterator_string(it), bson_iterator_string_len(it) - 1)); } else { ret->Set(String::New(key), - String::New(bson_iterator_string(it), bson_iterator_string_len(it))); + String::New(bson_iterator_string(it), bson_iterator_string_len(it) - 1)); } break; case BSON_NULL: diff --git a/node/nbproject/configurations.xml b/node/nbproject/configurations.xml index bd5be3b..8e4ba2b 100644 --- a/node/nbproject/configurations.xml +++ b/node/nbproject/configurations.xml @@ -2,6 +2,14 @@ + + + + + + + + diff --git a/node/tests/t2.js b/node/tests/t2.js index 6f8c5ad..7739739 100644 --- a/node/tests/t2.js +++ b/node/tests/t2.js @@ -32,7 +32,14 @@ module.exports.testSaveLoad = function(test) { test.equal(parrot1["_id"], oids[0]); test.ok(oids[1] == null); test.equal(parrot2["_id"], oids[2]); - test.done(); + + jb.load("parrots", parrot2["_id"], function(err, obj) { + test.ifError(err); + test.ok(obj); + test.equal(obj._id, parrot2["_id"]); + test.equal(obj.name, "Bounty"); + test.done(); + }); }); };