Hi, I’m implementing an API to create records for one type of object in
batches. I have model called kpivalues but the standard rest rules
mostly deal with acting on single records. So I’ve created an api where
using kpivalues with post, update or delete will execute create, update
or delete on a group of records defined in json as part of the body
request. I know that is no restful, I checked around and that was
pointed as a valid approach. I’m not obsessed with rest and anyway that
is not the doubt I have, though might be related.
In my controller api I receive the json and can iterate through the set
of entries in the json and create, update or delete for each kpivalue.
There are some checks to do before proceeding with the real action on
the object and it is all in the controller which makes it a bit too
crowded.
I know I should move that to the model (or somewhere else), but those
actions I do are auxiliary tasks like checking if the json parsing
fails, or checking if some element in the json for an entry is valid to
proceed, and so on.
Where would that code belong? Should I anyway move it to the model and
use it like Kpivalue::parseEntries for example? Should I use a module
and use it from the controller (I’m not sure what difference would that
make, I guess more testability but in the end it would be included in
the
controller anyway)?
One doubt I have is about memory consumption if I pass a big string of
json from the controller to the model, is that memory shared somehow
what are the implications of passing big data between controller and
models or modules (big string, say 5MB of data for example)
Any good hints?
Thanks.