我需要一些帮助来从DynamoDB中的嵌套JSONschema中获取项目。我会向你解释架构,你可以告诉我它是否可能。
架构是:
{
"updated_at": "2018/05/02 08:32:10",
"created_at": "2018/05/02 08:32:10",
"updated_by": "igor",
"created_by": "igor",
"application": [
{
"name": "driver app",
"features": [
{
"name": "passenger list",
"settings": [],
"description": "feature for passenger list",
"id": 2
}
],
"id": 1,
"url": "play store"
},
{
"name": "passsenger app",
"features": [],
"id": 2,
"url": "play store"
}
],
"address": "New York",
"id": 4,
"url": "https://airlink.moovex.com",
"name": "airlink",
"service_locations": [
{
"title": "IL",
"latitude": 32,
"longitude": 35
}
]
}
我需要从我的应用程序列表中获取带有查询的id的对象。
答案 0 :(得分:1)
我不确定这会回答您的问题但是,如果您需要检索具有特定ID的对象的应用程序列表,那么您会做什么
import boto3
DyDB = boto3.resource('dynamodb')
table = DyDB.Table('YourTableName')
response = table.query(
ProjectionExpression='application',
KeyConditionExpression=Key('id').eq(4) # where 4 is the id you need to query
)
# this is just to test the result
for app in response['Items'][0]['application']:
print(app['id'])
响应将返回(在列表项目中),应用程序属性及其中的应用程序列表