Skip to content

Commit 1be2ae3

Browse files
datastore: pass Buffers instead of base64s
1 parent ff68eb9 commit 1be2ae3

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

packages/datastore/src/entity.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ function encodeValue(value) {
268268
}
269269

270270
if (value instanceof Buffer) {
271-
valueProto.blobValue = value.toString('base64');
271+
valueProto.blobValue = value;
272272
return valueProto;
273273
}
274274

@@ -622,11 +622,7 @@ function queryToQueryProto(query) {
622622
};
623623

624624
if (query.endVal) {
625-
if (is.string(query.endVal)) {
626-
queryProto.endCursor = query.endVal;
627-
} else {
628-
queryProto.endCursor = query.endVal.toString('base64');
629-
}
625+
queryProto.endCursor = query.endVal;
630626
}
631627

632628
if (query.limitVal > 0) {
@@ -640,11 +636,7 @@ function queryToQueryProto(query) {
640636
}
641637

642638
if (query.startVal) {
643-
if (is.string(query.startVal)) {
644-
queryProto.startCursor = query.startVal;
645-
} else {
646-
queryProto.startCursor = query.startVal.toString('base64');
647-
}
639+
queryProto.startCursor = query.startVal;
648640
}
649641

650642
if (query.filters.length > 0) {

packages/datastore/test/entity.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ describe('entity', function() {
357357
var value = new Buffer('Hi');
358358

359359
var expectedValueProto = {
360-
blobValue: value.toString('base64')
360+
blobValue: value
361361
};
362362

363363
assert.deepEqual(entity.encodeValue(value), expectedValueProto);
@@ -881,8 +881,8 @@ describe('entity', function() {
881881
.end(endVal);
882882

883883
var queryProto = entity.queryToQueryProto(query);
884-
assert.strictEqual(queryProto.endCursor, endVal.toString('base64'));
885-
assert.strictEqual(queryProto.startCursor, startVal.toString('base64'));
884+
assert.strictEqual(queryProto.endCursor, endVal);
885+
assert.strictEqual(queryProto.startCursor, startVal);
886886
});
887887
});
888888
});

0 commit comments

Comments
 (0)