【问题标题】:Creating embedded entities with the datastore command line tool使用数据存储命令行工具创建嵌入式实体
【发布时间】:2017-05-02 13:51:18
【问题描述】:

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

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

以及如何创建数组值如下:

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

但我还没有弄清楚如何将嵌入值添加到数组中。例如:

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

给出错误: “此数组中的一个或多个值看起来不正确。如果包含值,请确保它们是 JSON 格式的 Datastore 数组值。”

【问题讨论】:

    标签: google-cloud-datastore


    【解决方案1】:

    我认为embeddedEntityValue 应该改为entityValue。下面是一个示例,它显示了一个包含两个嵌入实体的 Array 字段:

    {
      "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"
              }
            }
          }
        }
      ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-10
      • 2018-07-09
      • 1970-01-01
      • 1970-01-01
      • 2018-04-16
      相关资源
      最近更新 更多