【发布时间】:2018-02-20 21:55:47
【问题描述】:
我正在关注来自 Google documentation 和 Github 示例的 Cloud Datastore 示例,以及任务示例。我正在尝试进行单个函数调用,并通过在描述中查找任务将其标记为已完成。
function markDoneByDesc(queryString) {
const query = datastore
.createQuery('Task')
.filter('description', '=', queryString);
var taskKeyId;
datastore
.runQuery(query)
.then(results => {
const tasks = results[0];
console.log('Task found:', tasks[0]);
// I realize there might be multiple tasks with the same desc,
// but I want to update just one for now
taskKeyId = tasks[0][datastore.KEY].id;
console.log('Saving the task Key ID', taskKeyId);
return taskKeyId;
})
.then((taskKeyId) => {
console.log('Calling markDone with task Key ID', taskKeyId);
markDone(taskKeyId); // From the original function in the sample
console.log('Updated task');
})
.catch(err => {
console.error('ERROR:', err);
});
}
目前,更新不会发生 :(
【问题讨论】:
标签: node.js google-cloud-datastore google-cloud-sdk