简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM