I am having this question about having CRUD services built, I should be able to create, update, delete and get the records from the DB.
For easy understanding. I will use an example of a Company to which I should be writing services to perform the CRUD. I should add an employee, update an employee, delete an employee, get the list of employees that work for the company.
The below Object would be used as a request payload for Create/ Update/ Delete and The List of the EmployeeDomainObject would be used as the response for the Get request
EmployeeDomainObject
{
"firstName": "string",
"lastName": "string",
"id": "string",
"status": "ACTIVE" or "DELETE" or null
}
- Should I go with 2 services?
- 1 end-point for Get to get the List based on the company Id
- 1 end-point for Create/Update/Deletes that will accept the EmployeeDomainObject as the Request body and update the DB accordingly based on the status.
- If the request has status: null --> New Record ID would be null, on save one dynamic Id would be generated
- If the request has status: "ACTIVE" --> Update the record based on the ID
- If the request has status: "DELETE" --> Delete the record based on the ID
- Should I go with 4 services?
- 1 end-point for Get to get the List based on the company Id
- 1 end-point for Create to create the employee based on the EmployeeDomainObject
- 1 end-point for Update to update the employee based on the id in the EmployeeDomainObject
- 1 end-point for Delete to delete the employee based on the id in the EmployeeDomainObject
Scope and Requirements of the services: 1. Robustness 2. Maintainability 3. Which is more Service driven? 4. Scalable/ Extensible
Answers Appreciated