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

4

1 回答 1

1

我想你只想要这样的东西:

var key = ds.key(['Parent', parentId, 'Me']);
于 2015-08-21T23:33:07.873 回答