In User Model:
static columnNameMappers = snakeCaseMappers();
Query:
try {
const user = await User.query().insert(firstName, lastName});
res.send({ user, message: 'User profile is created' });
} catch (error) {
return next(new HttpError(400, error.message));
}
I'm getting error
"first_name: is a required property, last_name: is a required property"
If I change to await User.query().insert(first_name: firstName, last_name: lastName});. It works
Also, one strange thing is happening that if I use .sql(). I'm getting query like this 'select "user".* from "user"'
You have defined your jsonSchema using snake_case, so obviously it doesn't accept camel case.
jsonSchema is not the database schema, but the "input" schema for creating model instances.
After trying a lot I added these two lines
$parseJson(json, opt) { // De-Camelize key when creates Model Object
return super.$parseJson(decamelizeKeys(json), opt);
}
$formatJson(json) { //Camelize key for Model -> Json
return camelizeKeys(super.$formatJson(json));
}
Hi @koskimas, thanks for reply.. I found the issue.. It was typo in Model Json Schema like an idiot. I typed the required property as snake case.

I removed the two above two functions.. It's working.