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) { }); ~~~~ 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 { 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');