gpt4 book ai didi

javascript - 如何将空字符串作为 dynamodb 中字段的值传递?

转载 作者:太空宇宙 更新时间:2023-11-03 22:49:09 24 4
gpt4 key购买 nike

我正在尝试使用以下 json 数据执行 post 请求。但我需要一个字段,即“注释”作为空字符串值传递。当我这样通过时,出现错误:

'One or more parameter values were invalid: An AttributeValue may not contain an empty string'.

如何解决这个问题?

//json data which i need to post
{
"storeId": "106",
"addressId": "1",
"managerId": "1",
"name": "Syammohan",
"contactNo": "9656985685",
"notes": "",
"bookingType": "Weddding Consult",
"bookingDate": "2019-05-02",
"bookingTime": "09:00 am"
}

function bookingDone(employee) {
var {

storeId,
addressId,
managerId,
name,
contactNo,
notes,
bookingType,
bookingStatus,
bookingTime
} = req.body

console.log("notes", notes);

const params = {
TableName: "Booking",

Item: {
id: id,
storeId: storeId,
addressId: addressId,
managerId: managerId,
name: name,
contactNo: contactNo,
notes: notes,
bookingType: bookingType,
bookingStatus: bookingStatus,
bookingDate: bookingDate,
bookingTime: bookingTime,
employeeId: employee.id

},

};

docClient.put(params, (error) => {
if (error) {
console.log(error);
res.status(400).json({ error: 'Could not create booking' });
}
// queue.push(JSON.stringify({ event: 'booking.booking.created', model: { 'Bookings': params.Item } }));
res.send(params.Item)
// res.json({ id, name, info });

});
}

最佳答案

是的 Dynamodb 无法接受空字符串。因此编辑 aws 配置

var docClient = new AWS.DynamoDB.DocumentClient({ 转换空值:true });

这有效!

关于javascript - 如何将空字符串作为 dynamodb 中字段的值传递?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55946990/

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