Reputation: 377
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"
}
}
}
}
]
}
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."
Upvotes: 2
Views: 1418
Reputation: 2207
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"
}
}
}
}
]
}
Upvotes: 2