gpt4 book ai didi

node.js - 无法使用 node.js 上的 aws-sdk 更新 dynamoDb 上的项目

转载 作者:行者123 更新时间:2023-12-04 09:44:59 24 4
gpt4 key购买 nike

我正在尝试更新我的用户表上的项目。 email 是我的 HASH 键,id 是我的 RANGE

{
"accessToken": {
"M": {
"expirationDate": {
"N": "1622715427"
},
"token": {
"S": "dummy-auth-accessToken-xxx"
}
}
},
"email": {
"S": "xxx@toto.fr"
},
"firstName": {
"S": "Xxx"
},
"id": {
"S": "2"
},
"lastName": {
"S": "Yyyy"
},
"password": {
"S": "tataToto"
},
"refreshToken": {
"M": {
"expirationDate": {
"N": "1622715427"
},
"token": {
"S": "dummy-auth-refreshToken-xxx"
}
}
},
"username": {
"S": "XxxY"
}
}

我想更新访问和刷新 token ,所以我这样做:
const dynamoDb = new AWS.DynamoDB.DocumentClient();

const params = {
TableName: 'Users',
Key: { email: 'xxx@toto.fr' },
UpdateExpression: 'set #at1 = :1, #at2 = :2, #at3 = :3, #at4 = :4',
ExpressionAttributeNames: {
'#at1': 'accessToken.token',
'#at2': 'refreshToken.token',
'#at3': 'accessToken.expirationDate',
'#at4': 'refreshToken.expirationDate'
},
ExpressionAttributeValues: {
':1': 'new-dummy-auth-accessToken',
':2': 'new-dummy-auth-refreshToken',
':3': 1234567,
':4': 123456787654
},
ReturnValues: 'UPDATED_NEW'
}

dynamoDb.update(params, (err, data) => {})

但我得到了:
Unable to update item. Error JSON: {
"message": "The provided key element does not match the schema",
"code": "ValidationException",
"time": "2020-06-03T11:37:57.931Z",
"requestId": "PDTS2SDOEIOPMAO4VHGU6QM21JVV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 27.556977097280456
}

请问我做错了什么?

最佳答案

这是我的错...需要在 params 对象上添加 HASH 和 RANGE 键

Key: { 
id: "2"
email: 'xxx@toto.fr'
}

我的表达不好,但我知道如何解决它:)

ty 读 x)

关于node.js - 无法使用 node.js 上的 aws-sdk 更新 dynamoDb 上的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62172375/

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