Reputation: 389
I've just started to learn more about the project I'm working on. Turns out it uses GCP datastore. I went to the entity management interface. I created a new namespace and added an entity into it. In our typescript backend, I wrote a function that mimiced the example for node.js. However, I can't find out how to query the new namespace, or any namespace for that matter (besides the default namespace). I found some documentation that mentions namespaces, but none of it seemed to apply to my case. Does anybody know how I can query a particular namespace in the datastore?
async function listReviews( brand, sku ) {
const query = datastore.createQuery('Review').order('createdOn');
console.log('query: ', query);
const [reviews] = await datastore.runQuery(query);
for (const review of reviews) {
const reviewKey = review[datastore.KEY];
console.log(reviewKey.id, review);
}
}
Upvotes: 0
Views: 665
Reputation: 389
Turns out the call to createQuery takes an optional leading paramter... ie:
datastore.createQuery(namespace, kind)
default value of namespace must be [default] namespace.
Upvotes: 3