When I define my model in TypeORM as:
@Entity()
export class User {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ default: false })
isActivated: boolean;
}
I can use POST without any problem. However when I use PATCH it is expecting the id to be a numeric string:
{
"statusCode": 400,
"error": "Bad Request",
"message": "Validation failed. Param 'id': numeric string is expected"
}
The body I've sent is:
{
"id": "6aca65b8-ac87-4db8-a492-f4461655b5fa",
"isActivated": true
}
Please read this doc section.
so in your case, you should add this to the CrudOptions:
{
params: {
id: 'uuid'
}
}
Thanks! 馃憤
can you be more specific, i.e. in exactly which file to do the above mentioned modifications!
I'm using Get call but as my ID is uuid its giveing me error "Invalid param id. Number expected"
New version configuration is like this:
@Crud({
model: {
type: YourEntity,
},
params: {
id: {
type: 'uuid',
primary: true,
field: 'id',
},
},
})
Most helpful comment
New version configuration is like this: