1
\$\begingroup\$

I am working on a backend for an application using a microservice framework with Sequelize and it is populating in the following way (it does based on the table field):

{
   "resourceId":{
      "name":"Serra Eléctrica",
      "unitId":{
         "id":2,
         "name":"Hora"
      },
      "resourceTypeId":{
         "id":8,
         "name":"Patrimoniais"
      }
   },
   "quantity":8,
   "price":"9.00",
   "vat":"0.00"
}

The frontend developer said that this is bad because the objects are inside fieldId like resourceId.unitId.id instead of resource.unit.id. Is this really bad or is it actually irrelevant?

\$\endgroup\$
  • \$\begingroup\$ It's not really a 'resourceId' is it - It's a 'resource'. \$\endgroup\$ – Peilonrayz Jun 7 at 15:27
  • \$\begingroup\$ You're right, @Peilonrayz \$\endgroup\$ – André Jun 7 at 15:46
  • \$\begingroup\$ This is rather opinionated I guess. I can understand your frontend developer though as the content of all those xxxId fields does not only contain an ID but also a name and other other data. I also wonder about rest as the payload has nothing to do with REST. It does not contain links nor is a plain application/json a good media-type for REST also, as it lacks support for HATEOAS in particular \$\endgroup\$ – Roman Vottner Jun 7 at 15:50
  • \$\begingroup\$ @RomanVottner that payload is just a part of it but it is a RESTful API. Perhaps he is right and I will be changing that, it does not look good itself. \$\endgroup\$ – André Jun 7 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.