使用数据存储区命令行工具创建嵌入式实体 [英] Creating embedded entities with the datastore command line tool

查看:64
本文介绍了使用数据存储区命令行工具创建嵌入式实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google云数据存储区命令行界面来创建嵌入式实体的数组.我已经弄清楚了如何创建嵌入的实体值,如下所示:

I'm trying to use the Google cloud datastore command line interface to create arrays of embedded entities. I've figured out how to create an embedded entity value as follows:

{
    "properties": {
        "age": {
            "integerValue": "5"
        },
        "height": {
            "integerValue": "6"
        }
    }
}

以及如何创建数组值,如下所示:

and how to create an array value as follows:

{
    "values": [
        {
            "stringValue": "one"
        },
        {
            "stringValue": "two"
        }
    ]
}

但是我还没有弄清楚如何向数组添加嵌入值.例如:

But I haven't figured out how to add an embedded value to an array. For example:

{
    "values": [
        {
            "stringValue": "one"
        },
        {
            "stringValue": "two"
        },
        {
            "embeddedEntityValue": {
                "properties": {
                    "age": {
                        "integerValue": "5"
                    },
                    "height": {
                        "integerValue": "6"
                    }
                }
            }
        }
    ]
}

给出错误: 此数组中的一个或多个值看起来不正确.如果包含值,请确保它们是JSON格式的数据存储区数组值."

gives the error: "One or more values in this array doesn't look right. If you include values, make sure they are Datastore array values in JSON format."

推荐答案

我相信embeddedEntityValue应该更改为entityValue.下面是显示带有两个嵌入式实体的Array字段的示例:

I believe embeddedEntityValue should be changed to entityValue. Below is an example that shows an Array field with two embedded entities:

{
  "values": [
    {
      "entityValue": {
        "properties": {
          "areaCode": {
            "stringValue": "40"
          },
          "countryCode": {
            "stringValue": "91"
          },
          "subscriberNumber": {
            "stringValue": "2722 5858"
          }
        }
      }
    },
    {
      "entityValue": {
        "properties": {
          "countryCode": {
            "stringValue": "91"
          },
          "subscriberNumber": {
            "stringValue": "6666 0000"
          },
          "areaCode": {
            "stringValue": "80"
          }
        }
      }
    }
  ]
}

这篇关于使用数据存储区命令行工具创建嵌入式实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆