Quack Service & Controller

We will create our Quack service and controller

Having created the model we can now begin implementing the CRUD functionalities. We want to list, create, read, update, and delete the Quacks.

Quack Service#

We start with the service, so let's go over them one by one. We can start with the imports:

List Quacks#

The list method is straightforward. With larger applications you would want to have some filtering, sorting and pagination, but that is a bit outside of the scope of this course, and is usually handled by ORMs

Create Quack#

With a failsafe for missing data, this method creates a Quack with created_by and text while using default values for the rest.

Read Quack#

Here we simply pass in the id and return either the Quack or null

Update Quack#