Creating our models

In this service, we need to store the incoming orders in the database. The models we are creating in this section are representing that information in Swift through Fluent. Additionally, we also need to create input and output models that help us transfer the information from and to the user.

We have the following models to consider:

  • Order: This represents the order from a consumer.
  • OrderItem: This is an item within an order.
  • OrderPayment: This is a payment posted for an order.
When it comes to payments, make sure you always provide enough flexibility for different payment types and amounts. People are usually not as well-versed as we would like them to be for our services.

Let's go through the following sections: ...

Get Hands-On Swift 5 Microservices Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.