gpt4 book ai didi

amazon-dynamodb - InvalidParameterType : Expected params. ExpressionAttributeValues [':et1' ].N 为字符串

转载 作者:行者123 更新时间:2023-12-02 20:36:24 31 4
gpt4 key购买 nike

这是我用来进行查询的代码:

var scanParams = {
TableName : 'xxxx',
FilterExpression : '( (event = :e0) AND (event = :e1 AND eventTime > :et1 AND eventTime < :et2) )',
ExpressionAttributeValues: {
':e0': { S: 'ME 21' },
':e1': { S: 'ME 21' },
':et1': { N: 1509267218 },
':et2': { N: 1509353618 }
},
ProjectionExpression: "event, customer_id, visitor",
};

在相应的 dynamodb 表的配置中,我似乎为 eventTime 列添加了数字。

enter image description here

这里是错误:

error happened  { MultipleValidationErrors: There were 2 validation errors:
* InvalidParameterType: Expected params.ExpressionAttributeValues[':et1'].N to be a string
* InvalidParameterType: Expected params.ExpressionAttributeValues[':et2'].N to be a string
at ParamValidator.validate (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/param_validator.js:40:28)
at Request.VALIDATE_PARAMETERS (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/event_listeners.js:125:42)
at Request.callListeners (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at callNextListener (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at /home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/event_listeners.js:85:9
at finish (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/config.js:315:7)
at /home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/config.js:333:9
at SharedIniFileCredentials.get (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/credentials.js:126:7)
at getAsyncCredentials (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/config.js:327:24)
at Config.getCredentials (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/config.js:347:9)
at Request.VALIDATE_CREDENTIALS (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/event_listeners.js:80:26)
at Request.callListeners (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/sequential_executor.js:101:18)
at Request.emit (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/state_machine.js:14:12)
at Request.runTo (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/request.js:403:15)
at /home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/request.js:791:12
at Request.promise (/home/jahidul/workspace/backstage-opticon/node_modules/aws-sdk/lib/request.js:777:12)
at DynamoDBService.scanItem (/home/jahidul/workspace/backstage-opticon/shared/services/dynamodb/dynamodb.service.ts:52:39)
at /home/jahidul/workspace/backstage-opticon/job-scripts/dyno-test.js:57:12
at sailsReady (/home/jahidul/workspace/backstage-opticon/node_modules/sails/lib/app/lift.js:49:12)
at /home/jahidul/workspace/backstage-opticon/node_modules/async/lib/async.js:251:17
at /home/jahidul/workspace/backstage-opticon/node_modules/async/lib/async.js:154:25
at /home/jahidul/workspace/backstage-opticon/node_modules/async/lib/async.js:248:21
at /home/jahidul/workspace/backstage-opticon/node_modules/async/lib/async.js:612:34

有什么想法吗?提前致谢。

最佳答案

使用下面的参数:

var scanParams = {
TableName : 'xxxx',
FilterExpression : '( (event = :e0) AND (event = :e1 AND eventTime > :et1 AND eventTime < :et2) )',
ExpressionAttributeValues: {
':e0': { "S": "ME 21" },
':e1': { "S": "ME 21" },
':et1': { "N": "1509267218" },
':et2': { "N": "1509353618" }
},
ProjectionExpression: "event, customer_id, visitor",
};

在 Dynamo DB 中,类型(数字)由“N”表示,值必须为字符串格式“1509353618”。希望这能解决您的问题。

关于amazon-dynamodb - InvalidParameterType : Expected params. ExpressionAttributeValues [':et1' ].N 为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47011509/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com