gcloud nodejs datastore: how to create an entity with a parent?
Asked Answered
I

1

6

How to create an entity with a parent using gcloud, datastore and nodejs?

How to search for all the entities with a given parent?

Something like (this does not work):

var path = [{kind: 'Parent', id: parentId}, {kind: 'Me'}];
var key = ds.key(path);
var entity = {
  key: key,
  data: toDatastore(data, ['description'])
};
ds.save(entity)

Reading the docs I did not find any example of creating an entity with a given parent. I searched (without success) here: https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.19.1

while on the counterpart in python there are some specific proprieties to specify the parent entity: http://googlecloudplatform.github.io/gcloud-python/latest/datastore-keys.html

Please provide an example of code of how create and search for an entity with a parent

Invitation answered 21/8, 2015 at 10:39 Comment(0)
S
1

I think you just want something like:

var key = ds.key(['Parent', parentId, 'Me']);
Shoplifter answered 21/8, 2015 at 23:33 Comment(1)
The link returns 404 now. Working: cloud.google.com/datastore/docs/concepts/entitiesThanhthank

© 2022 - 2024 — McMap. All rights reserved.