gcloud nodejs datastore:如何使用父级创建实体?

all*_*que 6 node.js google-cloud-datastore gcloud-node

如何创建与父母使用的实体gcloud,datastore以及nodejs

如何搜索给定父级的所有实体?

像(这不起作用):

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

阅读文档我没有找到任何创建具有给定父级的实体的示例.我在这里搜索(没有成功):https: //googlecloudplatform.github.io/gcloud-node/#/docs/v0.19.1

而在python中的对应物上有一些特定的属性来指定父实体:http: //googlecloudplatform.github.io/gcloud-python/latest/datastore-keys.html

请提供有关如何使用父级创建和搜索实体的代码示例

Ste*_*hen 1

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

var key = ds.key(['Parent', parentId, 'Me']);
Run Code Online (Sandbox Code Playgroud)