Architecture doubt

I have a espace PROJ_DB where I have the entities and a PROJ_BK for a backoffice.

I want to do a CreateOrUpdate on an entity in the PROJ_BK and it seems that its a best practice to have the entities read only in the database espace and have server actions to insert on the database.

My doubt is, if the entitis are read only in the PROJ_DB, in the PROJ_BK espace I just have the GET action available.

So how can I do a CreateOrUpdate in the PROJ_BO using a server action? Its necessary to create a public server action in the PROJ_DB espace and then
add this server action to the PROJ_BO? But its ok to create a public server action for a CreateOrUpdate in the database espace?

Rank: #94

Hello Jake,

Hope you are doing well.

Usually, that is done using what is called as CRUD wrapper actions. Basically, you may create a Public server action which is going to call your CreateOrUpdate entity action (in PROJ_DB module). Then you just need to add this created action (CRUD wrapper) as a dependency in your PROJ_BK module and use it. This will allow you to maintain your entities as Read Only in your PROJ_DB module.

There are a lots of reasons to use this practice, instead of using entity actions directly. The main reason is related with the possibility to have a centralized location for any additional logic related with a create, delete, update or read of a record. Imagine for example that you want to have default values for some attributes everytime you want to create a new record. You may just place this logic in this wrapper and have a centralized location :)

Please, check this article written by MVP Justin James that should allow you to understand why this is a good practice and several benefits about using CRUD wrappers.

Hope that this helps you!

Kind regards,

Rui Barradas

Rank: #17137

Thanks, and do you know if the createOrUpdate wrapper also needs an output parameter with the movie id?