如何从索引查询两个值? Appsync查询DynamoDB
我的解析器模板
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
"expression" : "receiverusername = :receiverusername and createdat > :createdat",
"expressionValues" : {
":receiverusername" : $util.dynamodb.toDynamoDBJson($context.identity.username),
":createdat" : $util.dynamodb.toDynamoDBJson($ctx.args.input.lastDate),
}
},
"index" : "receiverusername-createdat-index",
}
我正在尝试查询日期和用户名,但是我一直在收到此错误,
{
"data": {
"listMyMessages": null
},
"errors": [
{
"path": [
"listMyMessages"
],
"data": null,
"errorType": "DynamoDB:DynamoDbException",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "One or more parameter values were invalid: Condition parameter type does not match schema type (Service: DynamoDb, Status Code: 400, Request ID: 7I18ODEK46H52NMBSF99OTNSQ7VV4KQNSO5AEMVJF66Q9ASUAAJG)"
}
]
该如何查询此问题?
我试图从文档中学习,但没有任何线索!
My resolver template
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
"expression" : "receiverusername = :receiverusername and createdat > :createdat",
"expressionValues" : {
":receiverusername" : $util.dynamodb.toDynamoDBJson($context.identity.username),
":createdat" : $util.dynamodb.toDynamoDBJson($ctx.args.input.lastDate),
}
},
"index" : "receiverusername-createdat-index",
}
I am trying to query the date and username but I keep on getting this error
{
"data": {
"listMyMessages": null
},
"errors": [
{
"path": [
"listMyMessages"
],
"data": null,
"errorType": "DynamoDB:DynamoDbException",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "One or more parameter values were invalid: Condition parameter type does not match schema type (Service: DynamoDb, Status Code: 400, Request ID: 7I18ODEK46H52NMBSF99OTNSQ7VV4KQNSO5AEMVJF66Q9ASUAAJG)"
}
]
How do I query this ?
I tried to learn from documentations but nothing gives me any clue!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于DynamoDB,不可能同时查询2个值,因为每个GSI都会创建一个具有不同索引的重复表。我能想到的一个很好的解决方案是并行查询索引并返回其交流。
Querying 2 values at the same time is not possible for DynamoDB, since every GSI creates a duplicate table with different index. A good solution I can think of is querying indexes in parallel and returning their intersaction.
我只是这样做了,它起作用了。
是的,我没有触摸或调查原因。
我没有使用排序键,而只是索引键
I just did this and it worked.
And yes I am not touching or investigating why.
I did not use sort key but just index keys