#Error : Can't insert null value in field id on insert in table

17 messages · Page 1 of 1 (latest)

turbid coral
#

the id is not generated automatically, I've created a new entity and created a POST endpoint but I have this error, if I add the id it works but I need it to be generated

forest summit
#

Can you share your model file for the new entity?

turbid coral
#

Hello @forest summit , yes here's the entity

forest summit
#

How do you create the entity in the endpoint? Could you maybe also share your create method of the custom entity service?

turbid coral
#

@forest summit here's the service

forest summit
#

That's strange, I have a similar setup up. The only difference is that I use repo.create() and pass that to the save method. But I doubt that it will make a difference.

turbid coral
#

can you send me what you're doing exactly I'll do the same and will see if it's going to work

forest summit
#
const created = reviewRepository.create(review)
const result = await reviewRepository.save(created)
#

This is the only difference in my create method

turbid coral
#

Ah yes, now it's working fine

#

Thank you @forest summit

forest summit
#

Oh nice!

#

No worries, glad I could be of help!

turbid coral
#

Hello Didier how are you?

#

I want to create a new page, do you have any idea how I can do that? I've followed their documentation but it doesn't work