Interacting with models

Fluent makes it very easy to communicate with models. For our template, we just need to keep the following things in mind:

  • Every database interaction happens on the eventLoop.
  • Define all models in the models folder. You can potentially create subfolders if you want to group some models together.
  • Usually, you need two models one for the DB and one for I/O. Combining the two can be dangerous.

Based on my own experience, I cannot emphasize enough how vital the third point is. You will be tempted to combine the two, but in almost all instances, you will end up having to rewrite your model numerous times because you have different requirements for I/O than for the DB.

Other than that, just stick to the way Fluent handles ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.