Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Models

Models are used to define the:

  • Source of data (D1, KV, R2)
  • Structure of data (properties and relationships)
  • REST operations that can be performed on the data (CRUD methods, custom methods)
  • Generated Client API

A single Cloesce Model encapsulates an entity that exists across the stack. Suprisingly, they’re only a couple of lines of code!

In this chapter, we will explore the various features of Cloesce Models, including defining D1, KV and R2 backed properties, relationships between Models, generated CRUD methods, and custom methods.