我使用Ryan Fitz' Vogels NodeJS包来访问DynamoDB。我在多个区域中有相同的表,我需要从单个NodeJS实例访问这些表。如何指定每个表的区域?
答案 0 :(得分:1)
您定义的每个模型都可以使用唯一的dynamodb客户端实例进行配置。
// Define models
var Account = vogels.define('Account', {hashKey :'email'});
var Product = vogels.define('Product', {hashKey :'productId'});
// Configure account models to use us-east-1
var dynamodbEast = new AWS.DynamoDB({region : 'us-east-1');
Account.config({dynamodb: dynamodbEast});
// Configure product models to use us-west-1
var dynamodbWest = new AWS.DynamoDB({region : 'us-west-1');
Product.config({dynamodb: dynamodbWest});