I am new into DynamoDB. I am trying to query a collection with two matching fields. I have written a code in MongoDB, I am trying to migrate to DocumentDB. I am facing an issue.
MongoDB Code
getUser= async(req,res)=>{ let user = await user.findOne({phone:123456789, otp:2345}); }
DynamoDB Code
getUser= async(req,res)=>{ const params = { KeyConditionExpression: 'phone = :phone and #otp = :otp', ExpressionAttributeValues: { ':phone': 919600923917, ":otp":2387 }, TableName: "users", }; const user= await documentClient.query(params).promise(); }
Issue: Invalid KeyConditionExpression: An expression attribute name used in the document path is not defined; attribute name: #otp