Google 应用程序制造商记录键值

Google App maker record key value

在应用程序制作器中,我们启用了手动保存模式。单击按钮将打开一个新表单,我们将创建一个空记录,当用户填写字段并单击保存按钮时,saveChanges 函数将保存所有值。

在文档和示例项目中,我可以看到在数据源中更新记录创建_key 值后,我们可以使用该键值从其子模型中查询记录。

但是在我们的例子中键值没有被返回。但是当我们打开记录键值时保存更改功能后,可能是什么问题。

在您保存之前,您在客户端上没有记录密钥,因为记录密钥是由服务器生成的。这适用于自动和手动保存模式。

这是代码 snippet from App Maker documentation:

 var myCreateDatasource = app.datasources.MyDatasource.modes.create;
 var draft = myCreateDatasource.item;
 draft.Name = "Name";
 draft.Age = 21;

 // Create the new item
 myCreateDatasource.createItem(function(newRecord) {
   // Callback is called after the record is saved, so it now has a key.
   var key = newRecord._key;
   // Do something with the key here.
 }