在Dynamodb中,您需要在索引中指定可用于进行查询的属性.
如何使用两个以上的属性进行查询?
使用boto的示例.
Table.create('users',
schema=[
HashKey('id') # defaults to STRING data_type
], throughput={
'read': 5,
'write': 15,
}, global_indexes=[
GlobalAllIndex('FirstnameTimeIndex', parts=[
HashKey('first_name'),
RangeKey('creation_date', data_type=NUMBER),
],
throughput={
'read': 1,
'write': 1,
}),
GlobalAllIndex('LastnameTimeIndex', parts=[
HashKey('last_name'),
RangeKey('creation_date', data_type=NUMBER),
],
throughput={
'read': 1,
'write': 1,
})
],
connection=conn)
Run Code Online (Sandbox Code Playgroud)
如何查找姓名为"John",姓氏为"Doe"并使用boto在"3-21-2015"创建的用户?