I am new in dynamoDB, I am trying to update and get item to db but i can't, always getting "The provided key element does not match the schema"
this my serverless.yml code for dynamoDB
resources:
Resources:
TodosDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
-
AttributeName: in_organization_id
AttributeType: S
-
AttributeName: sp_customer_id
AttributeType: S
-
AttributeName: qb_customer_id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
-
AttributeName: in_organization_id
KeyType: RANGE
-
AttributeName: sp_customer_id
KeyType: RANGE
-
AttributeName: qb_customer_id
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: 'insightly'
and this is my update method
/* Update Record in DB */
this.UpdateDB = (event) => {
return new Promise(async (resolve, reject) => {
try {
const data = event;
const params = {
TableName: process.env.TABLE_NAME,
Key: {
in_organization_id : data.in_organization_id
},
UpdateExpression: "set qb_customer_id = :qb_customer_id",
ExpressionAttributeValues:{
":qb_customer_id":data.qb_customer_id
},
ReturnValues:"UPDATED_NEW"}
const response=await dynamoDb.update(params).promise();
resolve(response);
} catch (err) {
reject(err.message);
}
});
};
like wise i have getmethod to get item
/* Get/Check Org ID from DB */
this.checkOrgID = (OrgID) => {
return new Promise(async (resolve, reject) => {
try {
const params = {
TableName: process.env.TABLE_NAME,
Key: {in_organization_id :OrgID}
};
const response = await dynamoDb.get(params).promise();
resolve(response);
} catch (err) {
reject(err.message);
}
});
};
but it always giving me error. Please help me to find out the solution. Thanks in Advance.