简体   繁体   English

如何从节点中的云数据存储中检索任何内容?

[英]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. 我尝试过的事情。

  1. Access using a key 使用钥匙访问
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;
    });
  1. Using a query 使用查询
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.

相关问题 无法使用节点从数据存储中检索数据 - Not able to retrieve data from datastore using node 如何从云数据存储中检索子实体而不在 nodejs 中传递父键 - How to retrieve a child Entity from a cloud datastore without passing a parent key in nodejs 如何在Google Cloud Datastore(Node.js)中执行“仅键查询” - How to do a “keys-only-query” in Google Cloud Datastore (Node.js) 如何使用Node JS从Google Cloud DataStore返回所有实体ID? - How to return all entity ids from google cloud datastore using node js? 如何从Openshift云中运行的节点服务器中检索会话Cookie - how to retrieve session cookie from a node server running in openshift cloud 从本地机器上运行的 Node 应用程序访问 Google Cloud Datastore - Access Google Cloud Datastore from Node app running on local machine 如何使用Google Cloud Datastore Node.js读取交易中的所有种类的实体 - How do I read all entities of a kind in a transaction with google cloud datastore nodejs 查询Google Cloud Datastore以检索匹配结果 - Query Google Cloud Datastore to retrieve matching results 如何将实体的实体关键字分配为数据存储区(Node JS)中其他实体的属性? - How do I assign an entity key of entity as a property of different entity in datastore (Node JS)? 如何在“使用严格”模式下跨多个节点模块将对象数组作为数据存储访问? - How do I access my object array as a datastore across multiple node modules in 'use strict' mode?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM