How to create an entity with a parent using gcloud
, datastore
and nodejs
?
如何使用gcloud,datastore和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
阅读文档我没有找到任何创建具有给定父级的实体的示例。我在这里搜索(没有成功):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
而在python中的对应物上有一些特定的属性来指定父实体: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
请提供有关如何使用父级创建和搜索实体的代码示例
1 个解决方案
#1
1
I think you just want something like:
我想你只想要这样的东西:
var key = ds.key(['Parent', parentId, 'Me']);
#1
1
I think you just want something like:
我想你只想要这样的东西:
var key = ds.key(['Parent', parentId, 'Me']);