如何表示存储谷歌云数据存储区中关键字段的数据

时间:2016-03-16 17:24:19

标签: node.js google-app-engine google-cloud-datastore

我在Google数据存储区设置了一个nodejs,并且有一个Kind - Event,其中实体one-many存在user - Key(User,'id')个关系

如何将数据存储/推送到此实体? 我试图发送整个用户json对象,并将user作为键,但它不起作用。

Table/Kind - Event
column/property - user which is of type Key(kind,id)

我将事件的对象传递为

{
'property' : 'value',
 How to represent data for key here??   
}


var ds = gcloud.datastore.dataset({projectId: 'pId'});

function create(data, kind, cb) {
    var entity = {
      key: ds.key(kind),
      data: toDatastore(data, ['description'])
    };

    ds.save(
      entity,
      function(err) {
        if(err) { return cb(err); }
        data.id = entity.key.id;
        cb(null, data);
      }
    );
}

0 个答案:

没有答案