Gcloud nodejs datastore: how to create an object with a parent?

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

How to search for all objects 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 documents, I did not find a single example of creating an object with this parent. I searched (without success) here: https://googlecloudplatform.imtqy.com/gcloud-node/#/docs/v0.19.1

while the analog in python has some specific properties to indicate the parent: http://googlecloudplatform.imtqy.com/gcloud-python/latest/datastore-keys.html

Please provide an example of code for creating and searching an object with a parent

+6
source share
1 answer

I think you just need something like:

 var key = ds.key(['Parent', parentId, 'Me']); 
+1
source

All Articles