英文:
Dynamodb query returns json with synthax error
问题
以下是您的代码的翻译:
let ddb = new AWS.DynamoDB(config)
export const dynamoDb = ddb
export const dynamoClient = new AWS.DynamoDB.DocumentClient({
service: dynamoDb
})
let params = {
TableName: auditTable,
IndexName: 'importId-auditStatus-index',
KeyConditionExpression: 'importId = :importId and auditStatus = :auditStatus',
ExpressionAttributeValues: {
':importId': importId,
':auditStatus': 'Imported'
}
}
let response = await dynamoClient.query(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
return data;
}
}).promise();
console.log("response",response)
JSON 数据部分没有发生语法错误。如果您有特定的问题或者需要帮助,请随时告诉我。
英文:
Connected to dynamoDb table using Nodejs, i want to fetch items from table. i tried using query option, it returns json with items but some times it returns Json with synthax error
This is my code
let ddb = new AWS.DynamoDB(config)
export const dynamoDb = ddb
export const dynamoClient = new AWS.DynamoDB.DocumentClient({
service: dynamoDb
})
let params = {
TableName: auditTable,
IndexName: 'importId-auditStatus-index',
KeyConditionExpression: 'importId = :importId and auditStatus = :auditStatus',
ExpressionAttributeValues: {
':importId': importId,
':auditStatus' : 'Imported'
}
}
let response = await dynamoClient.query(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
return data;
}
}).promise();
console.log("response",response)
Some times it returns Json with synthax error as given below
{
"Count":117,
"Items":[
... truncated by me ...
{
"pricingTemplate":{
"NULL":true
},
"auditId":{
"S":"7555555_15287101"
},
"importId":{
"S":"8c6976bb-8680-47ce-bcfb-470c8e97740f"
},
"auditStatus":{
"S":"Imported"
},
"Id":{
"S":"420f50cb-3d03-49cb-b1da-1a36aa099e6c"
},
"recordType":{
"S":"currecy_test_tl"
}
}
,{"pricingTemplate":{"NULL":true},"auditId":{"S":"7555555_15287164"},"importId":{"S":"8c6976bb-8680-47ce-bcfb-470c8e97740f"},"auditStatus":{"S":"Imported"}7555555_15287206"},"importId":{"S":"8c6976bb-8680-47ce-bcfb-470c8e97740f"},"auditStatus":{"S":"Imported"},"Id":{"S":"e7042719-fa77-4939-9d05-ad41f3bdc7dc"},"recordType":{"S":"currecy_test_tl"}},{"pricingTemplate":{"NULL":true},"auditId":{"S":"7555555_15287155"},"importId":{"S":"8c6976bb-8680-47ce-bcfb-470c8e97740f"},"auditStatus":{"S":"Imported"},"Id":{"S":"bee5d2e3-60cf-4ecf-8249-d25de6e8c28a"},"recordType":{"S":"currecy_test_tl"}},
{
"pricingTemplate":{
"NULL":true
},
"auditId":{
"S":"7555555_15287111"
},
"importId":{
"S":"8c6976bb-8680-47ce-bcfb-470c8e97740f"
},
"auditStatus":{
"S":"Imported"
},
"Id":{
"S":"2161a17f-63c5-4c45-b7b4-9750cc202b23"
},
"recordType":{
"S":"currecy_test_tl"
}
}
],
"ScannedCount":117
}
Edits:
Syntax error at auditStatus":{"S":"Imported"}7555555_15287206"},
答案1
得分: 0
你分享的代码和输出不对齐。代码中使用的文档客户端 dynamoClient
返回本机 JSON。代码中的低级客户端 dynamoDb
和 ddb
将返回 DynamoDB JSON,这是您输出并称之为语法错误的内容。
英文:
The code you're sharing and the output you shared are not aligned. The Document Client dynamoClient
which you use in the code returns native JSON. The low level client dynamoDb
and ddb
in your code will return DynamoDB JSON, which is what you are outputting and calling a syntax error.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论