我正在尝试使用官方 AWS 库dynamodb-data-mapper-js在 Node.js 中设置一个 DynamoDB 数据库来创建持久模型对象和数据映射器。但是,它似乎没有提及使用本地辅助索引或 GSI 创建表的任何内容。
我在 Github 中发现了一个关于如何使用 LSI 创建表的参考资料,提供的示例解释了引用 arangeKey和声明 LSI之间的区别:
@table('items')
class Item {
@hashKey({ // <-- this is your normal hash key (shared by table and of LSI)
indexKeyConfigurations:{
ItemIdIndex: 'HASH' // The key (ItemIdIndex) is the name of the index; the value is the key type ('HASH' or 'RANGE')
}
})
itemId: string;
@rangeKey() // <-- this is your normal range key (not part of LSI)
displayName: string;
@attribute({
// And this other attribute acts as the LSI's RangeKey
indexKeyConfigurations: {
ItemIdIndex: 'RANGE'
}
})
foo: string;
@attribute()
bar: string;
}
但是,我创建了一个表模型完全相同的表,但出现以下错误:
Error: No options provided for ItemIdIndex index at indexDefinitions
我无法获得更多信息,即使他们说他们支持,文档也没有说明任何关于 LSI 或 GSI 的内容。
墨色风雨
相关分类