The Data Layer

Data modeling is core to the development process. As our understanding of the design evolves, so must our code.

hof has a data modeling system that works with the code generation process.

  • define data models in CUE, couple these with and into code generators
  • generate language types, database tables, libraries, API handlers, and more
  • checkpoint the data model and maintain a history for version transforms and migrations

This section expands on our simple-server to use hof/dm.#Datamodel. We will first

  1. Create a todo application data model
  2. Generate Go types and a simple Library
  3. Start with a Go map for storage, later a database
  4. Create CRUD routes for the datamodel

After we will see hof’s code __re__generation capabilites by

  1. Customizing the generated code
  2. Updating the data model
  3. Regenerating our application
  4. Inspecting and discussing the result

Finally, we will look at how to upgrade our genertor to use a database. Automatic migrations are covered in the model history section.

The full code for this section can be found on GitHub code/first-example/data-layer

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

2022 Hofstadter, Inc