From 010a7df8750a7ccb6f0714f99d4a60679f7128ac Mon Sep 17 00:00:00 2001 From: Silvano Luciani Date: Thu, 17 Jul 2014 14:14:14 -0700 Subject: [PATCH 1/3] Fixed ds.get and ds.getAll examples. key and keys were missing in the callbacks. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c6feb818494..b5eee7a2efd 100644 --- a/README.md +++ b/README.md @@ -101,11 +101,11 @@ TODO Get operations require a valid key to retrieve the key identified entity from Datastore. Skip to the "Querying" section if you'd like to learn more about querying against Datastore. ~~~~ js -ds.get(['Company', 123], function(err, obj) { +ds.get(['Company', 123], function(err, key, obj) { }); // alternatively, you can retrieve multiple entities at once. -ds.getAll([key1, key2, ...], function(err, objs) { +ds.getAll([key1, key2, ...], function(err, keys, objs) { }); ~~~~ From 32476355eacb51f1a0e649e6d83fca8aa44cf105 Mon Sep 17 00:00:00 2001 From: Silvano Luciani Date: Thu, 17 Jul 2014 14:17:03 -0700 Subject: [PATCH 2/3] Type checking hackery for Boolean and Number primitive types. --- lib/datastore/entity.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/datastore/entity.js b/lib/datastore/entity.js index d07ee077bb5..dab99c9ad7f 100644 --- a/lib/datastore/entity.js +++ b/lib/datastore/entity.js @@ -180,7 +180,7 @@ module.exports.entityFromEntityProto = entityFromEntityProto; */ function valueToProperty(v) { var p = {}; - if (v instanceof Boolean) { + if (v instanceof Boolean || typeof v === 'boolean') { p.booleanValue = v; return p; } @@ -192,7 +192,7 @@ function valueToProperty(v) { p.doubleValue = v.get(); return p; } - if (v instanceof Number) { + if (v instanceof Number || typeof v === 'number') { if (v % 1 === 0) { p.integerValue = v; } else { From 01e782fc06ec8b7e857127d08046865ceda925a4 Mon Sep 17 00:00:00 2001 From: Silvano Luciani Date: Thu, 17 Jul 2014 15:10:26 -0700 Subject: [PATCH 3/3] Test valueToProperty with primitive boolean and number. --- test/datastore.entity.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/datastore.entity.js b/test/datastore.entity.js index 7eb4d4b4def..c69dde230db 100644 --- a/test/datastore.entity.js +++ b/test/datastore.entity.js @@ -182,6 +182,8 @@ describe('entityToEntityProto', function() { name: 'Burcu', desc: 'Description', count: new entity.Int(6), + primitiveCount: 6, + legit: true, date : now, bytes: new Buffer("Hello"), list: ['a', new entity.Double(54.7)], @@ -193,6 +195,8 @@ describe('entityToEntityProto', function() { assert.equal(proto.properties.name.stringValue, 'Burcu'); assert.equal(proto.properties.desc.stringValue, 'Description'); assert.equal(proto.properties.count.integerValue, 6); + assert.equal(proto.properties.primitiveCount.integerValue, 6); + assert.equal(proto.properties.legit.booleanValue, true); assert.equal(proto.properties.date.dateTimeValue, now); assert.equal(proto.properties.bytes.blobValue, 'SGVsbG8='); assert.equal(proto.properties.list.listValue[0].stringValue, 'a');