我"偷走" Google文档中的此示例:
function listTasks() {
const query = datastore.createQuery('Task').order('created');
datastore
.runQuery(query)
.then(results => {
const tasks = results[0];
console.log('Tasks:');
tasks.forEach(task => {
const taskKey = task[datastore.KEY];
console.log(taskKey.id, task);
});
})
.catch(err => {
console.error('ERROR:', err);
});
}
起初它没有工作,但是在我找到关于登录东西的答案之后我现在看到了一些结果。问题是......我试图显示1个集合中的所有实体。集合称为"任务"因为它也来自文档。它现在只有1个条目:
我看到控制台中只显示Tasks:
,而没有来自实际数据库的任何信息。官方代码有什么问题吗?
答案 0 :(得分:2)
Ok, I am slow. So the problem was that .order('created')
isn't a "built-in" functionality, I don't have that property in my collection so nothing to sort by. Weird that it wasn't causing an error because of that, but without it everything worked.