I have table with GSI and trying to delete item using GSI as below.
But I get following error.
"The provided key element does not match the schema".
I tried to query using following keyword and worked.
So I already confirmed the provided key element is right.
I tried to search whether delete operation by GSI is possible or not but could not find good documentation.
Could anyone tell me what is the best approach to delete item using GSI?
async function deleteProject(projectDB:string,projectId:string):Promise<any>{
const params={
TableName:projectDB,
IndexName:'projectId-index',
Key:{
'projectId':projectId,
},
ExpressionAttributeNames: { '#a': 'projectId' },
ExpressionAttributeValues: {":val": projectId},
ConditionExpression:"#a = :val",
}
const result=await db.delete(params).promise();
console.log('result',result);
return result;
}