[英]How do I retrieve anything from cloud datastore in node?
I'm trying to access data that I have stored in datastore (in datastore mode). 我正在尝试访问已存储在数据存储中的数据(以数据存储模式)。 For some reason, I can't access any data it seems.
由于某种原因,我似乎无法访问任何数据。
Things I've tried. 我尝试过的事情。
const datastore = new Datastore({projectId: '...'});
const key = datastore.key([<kind>, <id>]);
return datastore.get(key, (err, entity, x) => {
console.log("yolo", err, entity, x);
return entity;
});
const query =
datastore.createQuery(<kind>);
return datastore.runQuery(query, (err, e, nq) => {
console.log(err, e, nq);
return e;
});
Both of the above yields no result. 上述两种方法都没有结果。 I am 100% sure I have typed the
kind
correctly. 我100%确信我已经正确键入了
kind
。
So this was a stupid mistake on my end, but I keep the question in case someone else does the same mistake. 因此,这是我的愚蠢错误,但我保留此问题,以防其他人犯同样的错误。
What I did when I created the entry in datastore was that I put it in a namespace, but then I didn't provide the namespace when I queried for it. 在数据存储区中创建条目时,我所做的就是将其放在一个名称空间中,但是当我查询它时却没有提供该名称空间。 Just providing the namespace and I was all good.
仅提供名称空间,我一切都很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.