Я хочу создать таблицу User
по dynamoDB с некоторыми атрибутами, которые дизайн чванства:Как создать таблицу dynamodb с глобальными вторичными индексами
User {
id (string, optional): UUID of User ,
name (string, optional),
lastLoginedAt (string, optional),
avatar (Avatar, optional),
}
Avatar {
avatarId (string, optional):,
iconUri (string, optional),
message (string, optional),
}
и хотят User
воли ответ с JSON после putItem, как показано ниже:
{
"id": "string",
"name": "string",
"lastLoginedAt": "2016-06-24 15:28:26",
"avatar": {
"avatarId": "string",
"iconUri": "string",
"message": "string"
},
}
Я начинаю Dynamodb, и я все еще застрял в создании таблицы, здесь мой код:
$dynamodb->createTable([
'TableName' => 'User',
'AttributeDefinitions' => [
[ 'AttributeName' => 'id', 'AttributeType' => 'S' ],
[ 'AttributeName' => 'name', 'AttributeType' => 'S' ],
[ 'AttributeName' => 'avatar', 'AttributeType' => 'S' ]
],
'KeySchema' => [
[ 'AttributeName' => 'id', 'KeyType' => 'HASH' ],
[ 'AttributeName' => 'name', 'KeyType' => 'RANGE' ]
],
'GlobalSecondaryIndexes' => [
[
'IndexName' => 'avatarIndex',
'KeySchema' => [
[ 'AttributeName' => 'avatarId', 'KeyType' => 'HASH' ],
[ 'AttributeName' => 'id', 'KeyType' => 'RANGE' ]
],
'Projection' => [
'ProjectionType' => 'INCLUDE',
'NonKeyAttributes' => [ 'iconUri', 'message' ]
],
'ProvisionedThroughput' => [
'ReadCapacityUnits' => 5,
'WriteCapacityUnits' => 5
]
]
],
'ProvisionedThroughput' => [
'ReadCapacityUnits' => 5,
'WriteCapacityUnits' => 5
]]);
Это ошибки:
local.ERROR: Error executing "CreateTable" on "http://172.18.0.5:8000"; AWS HTTP error: Client error: `POST http://172.18.0.5:8000` resulted in a `400 Bad Request` response:{"__type":"com.amazon.coral.validate#ValidationException","message":"Global Secondary Index hash key not specified in At (truncated...)
ValidationException (client): Global Secondary Index hash key not specified in Attribute Definitons.Type unknown. - {"__type":"com.amazon.coral.validate#ValidationException","message":"Global Secondary Index hash key not specified in Attribute Definitons.Type unknown."}
Спасибо заранее!
Какая ошибка? –
@HarshalBulsara Я добавил (а) –