Adding a Data Model



Data modeling is core to the development process. As our understanding of the problem changes, so must our implementation.

hof has a data modeling system where you

  • define you data models in CUE
  • generate types, database tables, and API resources
  • checkpoint the data model and maintain a history
  • have the entire history available for generating migrations and tranformations

This section expands on our simple-server to use hof/dm.#Datamodel. We will generate Go types and a simple library around a Go map for storage. CRUD routes are also generated from the same datamodel as a Resource in API terminology. You will see how to customize both the code and the data model.

The full code for this section can be found on GitHub code/first-example/adding-a-datamodel

Database storage and automatic CRUD handler generation will be covered in more advanced sections.


dev note, swap todos for CUE values?

  • add extra section here for interesting CUE routes we could use?
2022 Hofstadter, Inc