Hi I know that the following error:
The provided key element does not match the schema
has a few answers on here but none of them helps me as I've already applied the advice to my problem and it still persists.
I'm using Dynamoose and Koa.js for my database and backend here is my model schema:
const userSchema = new dynamoose.Schema(
{
name: {
type: String,
trim: true,
required: true,
max: 32,
},
email: {
type: String,
trim: true,
required: true,
unique: true,
lowercase: true,
hashKey: true,
},
hashedPassword: {
type: String,
required: true,
},
salt: String,
resetPasswordLink: {
data: String,
default: '',
},
},
{ timestamps: true },
)
As you can see I've selected email
as my hash key as it's both required and unique.
Here's my code for the controller:
exports.signup = async (ctx) => {
if (ctx.status === 200) {
const { name, email, password } = ctx.request.body
try {
const foundUser = await User.get({ email })
//...
} catch (error) {
console.log(error)
}
}
}
When I make a post request with json values for name, email and password I get the following error. I've also tried User.get(email)
both throw the same error. Here is what is console logged in its entirety:
{
message: 'The provided key element does not match the schema',
code: 'ValidationException',
time: 2020-11-03T09:13:31.617Z,
requestId: '63C8C3G4UU3CGOT1A96KGF8TONVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 41.812765243942465
}
The usual solution found on here tells me to match what I'm searching with the hash key (partition key in AWS docs). I've already done that as I'm searching by email and have set email as my hash key. Can someone please help me with this issue?