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 regeneration capabilities by

  1. Customizing the generated code
  2. Updating the data model
  3. Regenerating our application
  4. See how hof fits into typical application development

Finally, we will look at how to upgrade our generator 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.


Schema for the Data Model
Generating Types for the server
API Resources from Data Models
Custom Code and iterative development with code gen
Relations between types and how to handle them
Checkpointing and Data Model history
Database upgrading the storage