我正在尝试使用 Sequelize ORM 的功能,该功能允许从包含的模型中引用嵌套列(请参阅Sequelize 文档:顶层的复杂 where 子句)。在文档中它指出,我可以使用$nested.column$语法。
以下是我试图做的:
let where = { memberId };
if (req.query.search) {
const like = { [Op.like]: `%${req.query.search}%` };
where = {
...where,
[Op.or]: [
{ '$bookItem.serial$': like },
{ '$bookItem.book.name$': like },
{ '$bookItem.book.ISBNCode$': like },
],
};
}
const options = {
where,
include: [
{
model: models.BookItem,
as: 'bookItem',
required: false,
include: [
{
model: models.Book,
as: 'book',
attributes,
required: false,
},
],
},
],
});
const transactions …Run Code Online (Sandbox Code Playgroud) 我的 AWS Lambda 函数有以下处理程序。我不想或不需要等待Promise.all解决或拒绝。因为,我对它的结果不感兴趣。我的目的是发送这些请求并完成。问题是,如果我删除关键字await(用箭头指向),请求就不会启动。但是,如果我输入关键字await,Lambda 函数需要运行并收费 3-5 秒,这对我来说并不划算。
你能解释一下我做错了什么吗?为什么没有关键字就不会发送请求await?
module.exports.handler = async (event) => {
try {
const urls = [/*some API urls*/];
--> await Promise.all(urls.map((url) => {
return axios.post(url, { email })
.catch((error) => {
console.log(error);
});
}));
return {
statusCode: 200,
body: JSON.stringify({ message: 'OK' }),
headers: {
'Content-Type': 'application/json',
},
};
} catch (error) {
return {
statusCode: 500,
body: JSON.stringify({ message: 'INTERNAL_ERROR' }),
headers: {
'Content-Type': 'application/json',
}
} …Run Code Online (Sandbox Code Playgroud) 调用 DynamoDB deleteItem API 时,出现The provided key element does not match the schema错误。经过研究,我发现当您没有提供完整的主键(即表有范围键但 API 调用未指定它)时,就会发生此错误。但是,就我而言,该表没有范围键,它只有一个名为 的哈希键pk。
这是我的代码:
const dynamodbDocClient = new AWS.DynamoDB.DocumentClient({ logger: console });
socket.on('my-event', async (payload) => {
await dynamodbDocClient.delete({
TableName: 'MyTable',
Key: { pk: payload.id },
}).promise()
})
Run Code Online (Sandbox Code Playgroud)
有人可以列出可能发生此错误的所有其他情况吗?