Skip to content

Commit 7ee76b3

Browse files
BenWhiteheadJustinBeckwith
authored andcommitted
fix: add parseInt to constructor of task keys (#436)
The `id` property of `Key` is a string, update the use site of the key to parse it as an int when being used to create a key.
1 parent 2edd95c commit 7ee76b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

samples/tasks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async function addTask(description) {
100100
// [START datastore_update_entity]
101101
async function markDone(taskId) {
102102
const transaction = datastore.transaction();
103-
const taskKey = datastore.key(['Task', taskId]);
103+
const taskKey = datastore.key(['Task', datastore.int(taskId)]);
104104

105105
try {
106106
await transaction.run();
@@ -133,7 +133,7 @@ async function listTasks() {
133133

134134
// [START datastore_delete_entity]
135135
async function deleteTask(taskId) {
136-
const taskKey = datastore.key(['Task', taskId]);
136+
const taskKey = datastore.key(['Task', datastore.int(taskId)]);
137137

138138
await datastore.delete(taskKey);
139139
console.log(`Task ${taskId} deleted successfully.`);

0 commit comments

Comments
 (0)