Javascript 如何在DynamoDB上用本地的globalsecondaryindex创建一个表?

Javascript 如何在DynamoDB上用本地的globalsecondaryindex创建一个表?,javascript,node.js,amazon-web-services,amazon-dynamodb,nosql,Javascript,Node.js,Amazon Web Services,Amazon Dynamodb,Nosql,我在Windows7上本地安装了DynamoDB。 我的项目是Node.js(0.12.0),我使用aws sdk 版本DynamoDB:2012-08-10 这项工作-> dynamodb.createTable({ TableName: 'Users', AttributeDefinitions: [{AttributeName: 'userId', AttributeType: 'S'}], KeySchema: [{AttributeName: 'userId', KeyType: 'H

我在Windows7上本地安装了DynamoDB。 我的项目是Node.js(0.12.0),我使用aws sdk

版本DynamoDB:2012-08-10

这项工作->

dynamodb.createTable({
TableName: 'Users',
AttributeDefinitions: [{AttributeName: 'userId', AttributeType: 'S'}],
KeySchema: [{AttributeName: 'userId', KeyType: 'HASH'}],
ProvisionedThroughput: {
    'ReadCapacityUnits': 5,
    'WriteCapacityUnits': 5
}
}, function () {
    ...
});
这不起作用->

dynamodb.createTable({
TableName: 'Users',
AttributeDefinitions: [{AttributeName: 'userId', AttributeType: 'S'}],
KeySchema: [{AttributeName: 'userId', KeyType: 'HASH'}],
ProvisionedThroughput: {
    'ReadCapacityUnits': 5,
    'WriteCapacityUnits': 5
},
GlobalSecondaryIndexes: [
    {
        IndexName: 'longitudeUserIndex',
        KeySchema: [
            {
                AttributeName: 'userId',
                KeyType: 'HASH'
            },
            {
                AttributeName: 'longitude',
                KeyType: 'RANGE'
            }
        ],
        Projection: {
            NonKeyAttributes: [
            ],
            ProjectionType: 'KEYS_ONLY'
        },
        ProvisionedThroughput: {
            'ReadCapacityUnits': 5,
            'WriteCapacityUnits': 5
        }
    }
]
}, function () {
    ...
});
docdynamodbjavascript:

我解决了我的问题

我添加了属性定义经度

AttributeDefinitions: [{AttributeName: 'userId', AttributeType: 'S'}, {AttributeName: 'longitude', AttributeType: 'N'}]