【问题标题】:How create a table on DynamoDB with a GlobalSecondaryIndexes in local?如何在本地使用 GlobalSecondaryIndexes 在 DynamoDB 上创建表?
【发布时间】:2015-04-01 23:18:12
【问题描述】:

我在 Windows 7 上本地安装 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 () {
    ...
});

DynamoDB Javascript 文档:http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#createTable-property

【问题讨论】:

    标签: javascript node.js amazon-web-services amazon-dynamodb nosql


    【解决方案1】:

    我解决了我的问题。

    我在 AttributeDefinitions 中添加了经度。

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

    【讨论】:

      猜你喜欢
      • 2022-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-14
      • 1970-01-01
      • 1970-01-01
      • 2021-02-09
      • 1970-01-01
      相关资源
      最近更新 更多